Securely Copy Folders and Files from one machine to another

Scp

I personally don’t like using USB keys to store critical information, they are very vulnerable to viruses and anyone can just steal it from you, so I started searching for a way to copy files and folders across computers in a secure way, and thats when I found scp.

This tool will copy files remotely via ssh, you just need to give the correct credentials for the remote machine and everything works like a charm, the commands are a little long because a lot of authentication takes place but you get used to it very fast.

Lets say you just configured a proxy server and firewall and that you want to backup that configuration to a file server on your network (scp works on any machine with ssh configured), the command would be:

sudo scp -r /etc/squid/ user@172.1.1.1:/home/common/squid

Where:

-r means recursive (copy all files and folder structure beginning with the one you specified, in our example, the whole squid folder get copied)

/etc/squid is the folder to be copied

user is your username on the REMOTE machine

/home/common/squid is the destination folder

If you want to copy a single file, just remove the -r option and replace the folder path with a file path (ie. /etc/squid/squid.conf)

I decided to do this short post because I have found the information on scp a little confusing for the newbies, because people tend to explain all functions and parameters and sometimes people just want to get things fast instead of learning every command and syntax scp has to offer.

Leave a Reply