Ubuntu10.10 and fedora14 use SCP for file transmission

Source: Internet
Author: User
Tags scp file scp command

The machine in the lab is mainly installed with two types of Linux, Ubuntu and fedora. We usually use USB flash drives to drag data away, which is inconvenient. So I will write a tutorial today, it teaches you how to use the SCP command that comes with Linux to implement file transfer.

1. Ensure that the two hosts can be pinged. For example, if one IP address is 192.168.82.1 (check the local IP Address: $ ifconfig), the user name is CITA, the IP address of the other machine is 192.168.82.2, and the user name is CITB.

Enter $ Ping 192.168.82.2 In the CITA terminal.

Ping 192.168.82.2 (192.168.82.2) 56 (84) bytes of data.
From 192.168.82.1 icmp_seq = 1 destination host unreachable
From 192.168.82.1 icmp_seq = 2 destination host unreachable
....

Indicates that the network connection is faulty. Check the network cable, network card, and other devices. If

Ping 192.168.82.2 (192.168.82.2) 56 (84) bytes of data.
64 bytes from 192.168.82.2: icmp_req = 1 TTL = 64 time = 0.229 MS
64 bytes from 192.168.82.2: icmp_req = 2 TTL = 64 time = 0.215 MS
64 bytes from 192.168.82.2: icmp_req = 3 TTL = 64 time = 0.224 MS

....

It indicates that the two machines are connected and you can proceed with the next step.


2. Use the SCP command to upload files.

For example, you can upload the/home/CITA/desktop/a file of CITA to/home/CITB/desktop/of CITB in two ways:

(1) enter the CITA desktop directory.

$ CD/home/CITA/desktop

Then execute the SCP command

$ Scp a citB@192.168.82.2:/home/CITB/desktop

Format:

$ SCP file name receiver username @ receiver IP Address: receiver path


(2) enter the complete sending path in any directory.

$ SCP/home/CITA/desktop/A citB@192.168.82.2:/home/CITB/desktop

Format:

$ SCP sending path + file name receiver username @ receiver IP Address: receiver path


Of course, you must have the password of the other user. For folders, use SCP-R. If you want to send all the folders in the current directory, SCP-R * is enough.


Get it done...


The following describes possible errors and exceptions.

1. If the file is transferred to the fedora system sub-host

SSH: connect to host 192.168.82.15 port 22: No route to host lost connection

It may be because the fedora system disables port 22 for transferring files by default. We can use the command to open it and enter the following on the Receiving Terminal:

$ Su

Enter the password, enter the highest permission, and enable port 22:

# Iptables-I input-P TCP -- dport 22-J accept

At this point, try the transmission command again. If the error still persists, go to the receiver and restart its sshd service with the highest permission. Be sure to enter the complete path name:

#/Etc/init. d/sshd restart

At this time, try again, and it should be successful.


2. If permission denied occurs, this issue is mainly caused by permission issues.

(1) first, check whether the file you want to send has the permissions that you can execute.

$ LS-l file name

View, if the permission is insufficient, you can use

$ Chmod 777 name of the file

To improve file permissions.

(2) Permission issues may be caused by path permissions.

Check whether you have the permission to write to the receiver path. For example, if you write to the/directory of the receiver when the permission is normal, the permission must be permission denie.


3. for warning: remote host identification has changed!


Because the receiver has been connected previously, the historical information of the receiver is stored in the Local Machine. As a result, the information of the receiver changes when the client is connected again, which is inconsistent with the historical information stored in the local machine, you only need to delete the historical information stored in the local machine.


Follow the prompts to go to/home/CIT/. Ssh/

$ CD/home/CIT/. Ssh/

Use the VI editor or gedit to open known_hosts

$ VI known_hosts

Or

$ Gedit known_hosts

Delete all the information in the file. Remember not to delete this file, but to open the file and delete the information in it...


So far, SCP file transmission should be done... If you have any questions, leave a message...












Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.