Remotely transfer files via SSH using SCP in Linux

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

Usage 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

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 /path/to/store/zip/

SCP 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

SCP 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

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s