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 cit

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.

Related Article

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.