Copy files/folders accross a network in Linux using ssh, tar, scp and rsync.

SCP or secure copy is probably the easiest of all the methods, its is designed as a replacement for rcp, which was a quick copy of cp with network funcationability. Before scp does any copying it first connects via ssh. SCP encrypts data over your network connection, but by using the -C switch you can compress the data before it goes over the network. This can significantly decrease the time it takes to copy large files.

scp -r directory user@server:~/

or default port

scp "-P 7787" -r directory user@server:~/

TAR is usually used for achiving applications, but what we are going to do in this case is tar it then pipe it over an ssh connection. TAR handles large file trees quite well and preserves all file permissions, and works quite well with symlinks.

tar -czf - directory | ssh -p 7787 user@server tar -xzf - -C .

or default port

tar -czf - directory | ssh user@server tar -xzf - -C .


tar -xzf - directory | ssh user@server "cat > /directory/tarball.tar.gz"


dpkg -l | ssh user@server "cat > /directory/dpkg-list.txt"

RSYNC speciality lies in its ability to analyse files and only copy the changes made to files rather than all files. This can lead to enormous improvements when copying a directory tree a second time.

rsync -avze "ssh -p 7787" directory user@server:~/

or default port

rsync -avze ssh directory user@server:~/

SSH backdoor.

SSH from hades to with the -R flag. I’ll assume that you’re the root user on hades and that tech will need the root user ID to help you with the system. With the -R flag, you’ll forward instructions of port 2222 on to port 22 on hades. This is how you set up an SSH tunnel. Note that only SSH traffic can come into hades: You’re not putting hades out on the Internet naked.

You can do this with the following syntax:

# ssh -R 2222:localhost:22

Once you are into, you just need to stay logged in and enter a command like:$ while [ 1 ]; do date; sleep 300; done

to keep the machine busy and minimize the window.
Now instruct your friends to SSH as “username” into without using any special SSH flags. You’ll have to give them your password:

root@hades:~# ssh .

BTW no need

Once user is on the, they can SSH to earth using the following command:$: ssh -p 2222 root@localhost

Short form:

from earth: ssh -R 2222:localhost:22
then: while [ 1 ]; do date; sleep 300; done
from hades: ssh -p 2222 root@localhost
and we can log in into :))

SSH login without password.

If you need to login from a serverA to a serverB using no password.

First what you have to do is login to a serverA as a user to generate a pair of authentication keys.
Do not enter a passphrase!

user@serverA:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/
The key fingerprint is:
90:48:02:a5:3a:55:28:91:e2:29:7d:f8:e6:93:a1:e4 user@serverA

Now use the ssh to create a directory ~/.ssh as a user “user” on a serverB. The directory may already exist there, in this case do not create that directory:

user@serverA:~> ssh user@serverB mkdir -p .ssh
user@serverB password:

Finally copy a new public key to user@serverB .ssh/authorized_keys and enter the userB password the last time:

user@serverA:~> cat .ssh/ | ssh user@serverB 'cat >> .ssh/authorized_keys'
user@serverB password:

From now, you can login to a serverB as a user “user” from a serverA without typing a password.