SCP – Secure Copy

We all know about FTP (file transfer protocol), FileZilla, Cyberduck and friends – utility tools that allow developers to transfer files between clients and servers. I’ve used FTP over a million times in my development career. From backing up files, migrations, or new fresh installations of some framework or CMS system – like WordPress.

Well there will be some situations where you you might need the help of Unix’s scp – or secure copy. This is a command you have to run so those of you that’s never fired up the terminal will need to get your hands dirty with it. Play around and run some commands and make some mistakes – well in a sandboxed environment, don’t want to totally delete your entire life’ work.

One of the benefits that I like about scp is that it is secure. Yeah you extreme cyber security folks will have counters for this but nothing is 100% secure, but scp does a pretty good job of it. Another benefit is speed – when you fire up this command the processing speed between client and server is much faster than that of FTP.

More often I run into situations where I need to transfer files from client to server – a good example would be transferring wordpress files, a fresh install.


// -r flag means recursively scan directories and subdirectories 
// and transfer those too
scp -r wordpress/* username@host.com:/home/wordpress/site.com

Once that’s run, you’ll see the program do its work.

Secure Copy Transfer

Let it finish processing, it’ll take a while depending on how large the directory (you’re transferring to the server from your local drive) is.

Once that’s complete you can simply verify by logging into your server and checking that the files are there. Something very important to note is the “-r” flag, don’t forget this when running the scp command. The “-r” flag just means you are wanting to grab EVERYTHING and transfer EVERYTHING from one server to another. If you don’t run the “-r” flag, only top level directories and files are transferred. You will be wondering why some files are missing and why you’re program or software isn’t running properly. So archive this in your brain somewhere.