Post

Using SCP to transfer files

Using SCP to transfer files

Background

scp — OpenSSH secure file copy

scp copies files between hosts on a network

Upload

Transfer data.zip into path /home/ubuntu/target/ on server2

1
scp data.zip user1@server2:/home/ubuntu/target/

Transfer data.zip into path /home/ubuntu/target/ on server2 (using user1PrivateKey ssh key)

1
scp data.zip -i /home/ubuntu/keys/user1PrivateKey user1@server2:/home/ubuntu/target/
-i identity_file
             Selects the file from which the identity (private key) for public key authentication is read.  This option is directly passed to ssh(1).

Download

Downloads all files from path /home/username/folder/ on dnsiphostname

1
$ scp user@dnsiphostname:/home/username/folder/*.* .

Downloads file1.zip from path /home/username/folder/ on dnsiphostname

1
$ scp user@dnsiphostname:/home/username/folder/file1.zip

Sources

Photo by Jakub Żerdzicki on Unsplash

Want to thank me?

🤝 Buy me a coffee https://buymeacoffee.com/dbplatz

This post is licensed under CC BY 4.0 by the author.