How to use SSH to copy remote files from a server to your local machine.

 


This simple one-liner will copy all files into a tarball, send the compressed files over a secure SSH connection and then uncompress the files into a local directory.

┌──(dush㉿DESKTOP-PF01IEE)-[~/website]
└─$ ssh bejiitas@192.168.220.115 -p 2222 "cd arma3/ ; tar cBf - ." | tar xvBf -
bejiitas@192.168.220.115's password: 
./
./README
./example_urllist.txt
./example_config.xml
./sitemap_gen.pl

This parameter to SSH will do this.

"cd arma3/ ; tar cBf - ." | tar xvBf -

A very useful tip to quickly copy files over SSH if you do not wish to use rsync. And it is fast as well. Just have your SSH password ready when prompted, this is a good tip for a regular SSH user.

Here is another version. This will save just the tar file containing the files I wish to download.

┌──(dush㉿DESKTOP-PF01IEE)-[~/website]
└─$ ssh bejiitas@192.168.220.115 -p 2222 "cd ssl/ ; tar cBf - ." > me.tar
bejiitas@192.168.220.115's password:

This is all very useful. This tars up the whole folder in one go and then transfers the file to your local machine over SSH. This should save a lot of time and is more secure than FTP.

0 Comments