vaheeD khoshnouD

linux, mikrotik, macosx

Remotely transfer files via SSH using SCP in Linux (with Examples)

Written by vaheeD on December 31, 2012
4.00 avg. rating (84% score) - 1 vote

Ever needed to quickly transfer a few files across to a remote host whilst in SSH? What about transferring a cPanel cpmove file? Perhaps you need to fetch a website from a remote server? SCP is for you. It provides the same level of authentication as SSH, and it’s extremely easy.

Secure copy or SCP is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol. – Wikipedia

Example of Remotely Transferring Files using SCP (Secure Copy)

If you wanted to transfer a file from your server to another server, simply issue the following to do so:

scp mylocalfile.txt [email protected]:/recipient/directory/

Example of Remotely Fetching Files using SCP (Secure Copy)

Let’s say you wanted to fetch an entire website that has been zipped up on a remote host, you could issue:

scp [email protected]:/path/to/zip/mywebsite.zip /path/to/store/zip/

Error “SCP port 22 connection refused”

If you’re receiving this error, it’s most likely because the remote hosts’ port has been changed. You can specify a port using the -P flag, e.g.:

scp -P 2211 mylocalfile.txt [email protected]:/recipient/directory/

Error “SCP SSH no such file or directory”

If you encounter this error, it might be because you are not specifying a directory. If you would like to send or receive a file from the root directory of the remote host, you will need to specify it as such:

scp mylocalfile.txt [email protected]:/
..
4.00 avg. rating (84% score) - 1 vote

Posted Under: Linux

About vaheeD

Leave a Reply

Your email address will not be published. Required fields are marked *

Protected by WP Anti Spam