Linux : SSH : SCP : Download/Upload files from/to server/EC2 using SSH/SCP

Yes, its easy to download files from server and upload files to linux server where SSH tunneling is possible. To do so you must have SSH/SCP installed in your system and shared/exchanged public keys or you have the server credentials.

To know more about OpenSSH see the following link

http://www.tecmint.com/install-openssh-server-in-linux/

to download files from server to local use following command

$ scp -P [port_number] user@your_site.com:[path/to/file/to/be/copied/in/server] [/destination/in/local/computer]
# Example
$ scp -P [port_number] user@your_site.com:/opt/nginx/conf/nginx.conf ~/Desktop

to upload files to server from local use following command

$ scp -P [port_number] [/file/location/in/local/computer] user@your_site.com:[path/to/target/in/server]
# Example
$ scp -P [port_number] ~/Desktop/text.conf user@your_site.com:/opt/nginx/conf/

-P [port_number] is optional. The default port for SSH client connections is 22

Other ways to do that

$ ssh host 'cat /path/on/remote' > /path/on/local

or

$ cat /path/on/local | ssh host 'cat > /path/on/remote'

Point to remember:

In case of SSH we use -p [port_number] while in case of SCP -P [port_number] is used

To change the SSH port follow the given link http://www.liquidweb.com/kb/changing-the-ssh-port/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s