How to Use SCP Command to copy file between server and local
SCP means secure copy. This command is used to copy files between hosts. It is also known as remote file copy command. Its secure because it is using same authentication as SSH command. We will see how to copy file from server to local computer and vice versa.
Copy file from server to local computer in linux
#syntax scp -P port username@hostname:/filepath localpath #example scp -P 20017 root@example.com:/var/www/html/myfile.zip /home/codextblog/Downloads/
Above command will copy myfile.zip
from remote computer to your computer under Downloads
directory. You can ignore port option if your server is using default port.
Copy file from local computer to server in linux
#syntax scp localpath username@hostname:/filepath #example scp /home/codextblog/Downloads/mysecondfile.zip root@example.com:/var/www/html/
Above command will copy mysecondfile.zip
file from your computer to remote computer under html
directory.
SCP command with private key authentication
Sometimes you need a identity file, generally a private key file is required to authenticate your local machine identity. In that case you have to pass key file in your SCP command as below.
#syntax scp -i privatekey.pem username@hostname:/filepath localpath #example scp -i my-ec2.pem ec2-user@example.com:/home/ec2-user/test.sql /home/codextblog/Downloads/
Leave a Comment
(0 Comments)
Useful Magento 2 Articles
Author Info
Chirag
Connect With Me