Bootstrap FreeKB - Linux Commands - scp (transfer files using secure copy protocol)
Linux Commands - scp (transfer files using secure copy protocol)

Updated:   |  Linux Commands articles

On a Linux System, the most popular ways to transfer a file from one Linux system to another Linux system are:

For example, scp or rsync could be used to transfer example.jpg from Machine 1 to Machine 2, or vice versa.

The Secure FTP (SFTP) command can be used to securely transfer files between Mac, Linux and Windows systems.

upload / push / PUT

In this example, foo.txt is transferred from server1 to the /tmp directory on server2.

[john.doe@server1 ~]# scp /tmp/foo.txt jane.doe@server2:/tmp
example.jpg        100$ 12  0.7KB/s  00:02

 

In this example, foo.txt and bar.txt on server1 are transferred to the /tmp directory on server2.

[john.doe@server1 ~]# scp /tmp/foo.txt /tmp/bar.txt jane.doe@server2:/tmp
foo.txt        100$ 12  0.7KB/s  00:02
bar.txt        100$ 12  0.7KB/s  00:02

 

Be aware that if the files contain whitespace, you'll want to wrap the full path to each file in quotes.

[john.doe@server1 ~]# scp '/tmp/hello world.txt' jane.doe@server2:/tmp
hello world.txt        100$ 12  0.7KB/s  00:02

 

download / pull / GET

In this example, example.jpg is transferred from server2 to server1.

[john.doe@server1 ~]# scp jane.doe@server2:'/home/jane.doe/example.jpg' '/home/john.doe'
example.jpg        100$ 12  0.7KB/s  00:02

 

Passwordless Authentication

Refer to public key authentication with OpenSSH (passwordless auth) for the steps on how to connect using a public private keypair.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter ff5b64 in the box below so that we can be sure you are a human.