How to use scp to download files from a remote machine over a secure encrypted connection.

This is the sample command I am using to download my OpenVPN keys from a remote VPN server to allow me to setup a local connection. And to backup the keys safely.

[1][email protected] ~ $ scp -i Goku.pem -P 443 [email protected]:/home/ubuntu/easy-rsa/keys/*.* /home/homer/vpn/
01.pem                                                                                                                   100% 5589     5.5KB/s   00:00
ca.crt                                                                                                                   100% 1736     1.7KB/s   00:00
ca.key                                                                                                                   100% 1704     1.7KB/s   00:00
dh2048.pem                                                                                                               100%  424     0.4KB/s   00:01
gmail.crt                                                                                                                100% 5589     5.5KB/s   00:00
gmail.csr                                                                                                                100% 1110     1.1KB/s   00:00
gmail.key                                                                                                                100% 1704     1.7KB/s   00:01
index.txt                                                                                                                100%  132     0.1KB/s   00:00
index.txt.attr                                                                                                           100%   21     0.0KB/s   00:00
index.txt.old                                                                                                            100%    0     0.0KB/s   00:00
serial.old                                                                                                               100%    3     0.0KB/s   00:00

Very useful when you do not have direct access to a machine.

You may also use sftp to connect to a remote machine.

[1][email protected] ~ $ sftp -i Goku.pem -P 443 [email protected]
Connected to

Then you may list the contents of the remote home directory.

sftp> dir
asterisk-12-current.tar.gz            asterisk-12.4.0                       dahdi-linux-complete-2.10.0+2.10.0    dahdi-linux-complete-current.tar.gz
easy-rsa                              freepbx                               iksemel-1.4                           iksemel-1.4.tar.gz
jansson                               libpri-1.4-current.tar.gz             pjproject

And download this to the local machine.

sftp> get iksemel-1.4.tar.gz
Fetching /home/ubuntu/iksemel-1.4.tar.gz to iksemel-1.4.tar.gz
/home/ubuntu/iksemel-1.4.tar.gz                                                                                          100%  503KB 503.5KB/s   00:01

No comments have been made. Use this form to start the conversation :)

Leave a Reply