Using SCP to copy files remotely in Linux

Source: Internet
Author: User
Tags scp command
SSH provides instructions and shell for logging on to the remote server. By default, it does not allow you to copy files, but still provides a "SCP" command.

Suppose you want to copy a file named "dumb" in the current directory of the Local Computer to your home directory on the remote server www.foobar.com. The name of your account on the remote server is Bilbo ". You can use this command:

SCP dumb bilbo@www.foobar.com :.

Copy the file back and use this command:

SCP bilbo@www.foobar.com: Dumb.

"SCP" calls SSH to log on, copy the file, and call SSH to close the connection.

If your "~ The/. Ssh/config file has already configured www.foobar.com as follows:

Host * FBC
Hostname www.foobar.com
User Bilbo
Forwardagent Yes

Then you can replace "bilbo@www.foobar.com" with "FBC", and the command is simplified to "SCP dumb FBC :.".

"SCP" assumes that your home directory on the remote host is your working directory. If you use a relative directory, it is relative to the home directory.

The "-R" parameter of the "SCP" command allows recursive directory copying. "SCP" can also copy files between two different remote hosts.

For more information about SSH, see the http://www.linuxaid.com.cn/engineer/brimmer/html/ssh.htm

SCP user @ host:/path/to/Files local_file_name

Copy to remote
SCP local_file_name user @ host:/path/to/Files
Copy directory to remote
SCP-r local_file_name user @ host:/path/to/Files

FTP:

Wget ftp://ftp.isc.org/isc/bind9/9.2.2/bind-9.2.2.tar.gz

Http://blog.chinaunix.net/u/8983/showart.php? Id = 55609

Http://www.unix206.com/8/166189.html

SCP command

The SCP command is the most convenient and useful command in SSH. Just use the SCP command to directly transfer files between two servers. You can run it as root on a server # SCP servername:/home/FTP/pub/file1. in this way, the file/home/FTP/pub/file1 on the other server is directly transferred to the current directory of the machine. Of course, you can also use # SCP/tmp/file2 servername: /boot sends/tmp/file2 files on the local machine to the/boot directory of another machine. The entire transfer process is still encrypted using SSH.

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.