Download or upload a file over SSH

#Copy something from this system to some other system:
$> scp /path/to/local/file username@hostname:/path/to/remote/file          
 
#Copy something from some system to some other system:
$> scp username1@hostname1:/path/to/file username2@hostname2:/path/to/other/file   
 
#Copy something from another system to this system:
$> scp username@hostname:/path/to/remote/file /path/to/local/file

You can add a port with the -P param

You can do it recursive with the -r param

HINT: If you got an “Too many authentication failures for X” errror, you can add the param -o PubkeyAuthentication=no .

If you couldn’t  authenticate via ssh key,  you can use sshpass to authenticate via password:

$> sudo apt-get install sshpass # Installation under Debian/Ubuntu
$> sshpass -p "TOPSECRETPASSWORD" scp username@hostname:/path/to/remote/file /path/to/local/file

 

Leave a Reply

Your email address will not be published.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.