Skip to content

How to duplicate a complete folder with subfolders over SSH using command line only (SCP)

When I got my first dedicated server, I spent a decent amount of time trying to configure some FTP server (one of them was ProFTPD, I believe there was another one but I forgot its name). It was a massive headache, and in the end, not even secure since transfers aren’t encrypted. I eventually found out that transferring files is just as easy over SSH, using for instance the SFTP abilities of FileZilla. It’s secure (encrypted properly), and requires no setup since it just uses the SSH daemon that comes with any minimalistic server setup.

So, after that I started using SFTP withing FileZilla. But I still didn’t know how to use SFTP from the console so I still used FTP there, the few times I had to. I’m not very at ease with it though, but with my tiny cheatsheet, all was fine 🙂 Until I had to connect to a server without an FTP daemon installed. I then found out that switching to SFTP is trivial: take the cheatsheet, but use it with “sftp” instead of “ftp”. For instance: sftp Captain Obvious to the rescue.

Ok, that’s the first “problem” solved. The second now, is that I wanted to copy a whole folder, recursively with all its subfolders and stuff. And I didn’t find a way to manipulate “get” (cf the cheatsheet) to do that. But I eventually found about “scp” aka “secure copy”. This thing is part of the minimalist installation of, for instance, Debian, and runs like:
scp -r /local/path/to/copy/to/
The very important part here is “-r” for recursive. For more options you can check the man page, but for the purpose of recursively duplicating a folder, that command line is enough.

PS: kudos to swraman

Posted in FTP, Linux, servers.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

or, reply to this post via trackback.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA