22

I want to rsync between two computers on my LAN with IP-adresses 192.168.20.9 and 192.168.20.10 both running Ubuntu 10.10.

I want to try rsync and ssh service between the two computers.

sakjur
  • 850
joe1983
  • 545

3 Answers3

25

I am assuming you want to be able to do this both ways, that your username of the logged in user is the same on both machines, that you are happy to get it working as quickly and as simply as possible and that you don't require to use keys to do this.

The steps are:

Set up ssh

You need to install the packages openssh-client and openssh-server Then from 192.168.20.9, check you can connect to 192.168.20.10

ssh 192.168.20.10

You will be prompted for the password of your use on 192.168.20.10. Enter that to continue. When asked if it is okay to connect, say yes.

Repeat the process the other way.

rsync files

To copy a file called todo.txt from your Desktop on 192.168.20.10 to 192.168.20.9, you can do this when logged into 192.168.20.9:

rsync -av 192.168.20.10:Desktop/todo.txt ~/Desktop/todo.txt

Or the other way, when logged into 192.168.20.10:

rsync -av ~/Desktop/todo.txt 192.168.20.9:Desktop/todo.txt

Make it easier.

On machine 192.168.20.9 you can add 192.168.20.10 as a network place in Nautilus under File > Connect to Server and choose ssh and enter your username, password etc. Set this up the other way round on 192.168.102.10. You can then use Nautilus to copy files using scp, ...which is nice.

Oli
  • 293,335
  • Thanks for the valuable suggestions ...i have made finally made a vdieo on rsync over ssh and posted on youtube. http://www.youtube.com/watch?v=4TTaPOAZnSA – joe1983 Feb 21 '12 at 12:07
  • @joe1983: Nice one. If you are happy that the answer is correct you can mark it as accepted. – Richard Holloway Feb 21 '12 at 20:00
0

Good answers already, but I thought I would add a few more explicit options, especially the use of --dry-run or -n, -z, compression, to speed things up, and --exclude to remove unnecessary transfers:

# Dry run - remove n to actually do it
rsync -anvz --exclude ".vscode" --exclude "GPUCache" --exclude ".pytest_cache" --exclude "pdf_proof" --exclude ".git" --exclude "docker_pdf_output" --exclude "working" --exclude "venv" --exclude ".DS_Store" --exclude "document.egg-info" --exclude "__pycache__" --exclude ".mypy_cache" dev@192.168.1.13:/remote/path/to/directory/ ~/local/path/to/directory

Please note the trailing slash on the source and the missing trailing slash on the destination - so that you don't put the source directory inside the destination directory, but rather the source's contents inside the destinations directory.

Joe
  • 101
0
rsync -av -e 'ssh -o PubkeyAuthentication=no' \
  'remote_user@192.168.20.10:~/remote/file' 'local/file'

may be easier to setup, as it does not require passing public keys areound, and it prevents "Too many authentication failures for username" https://superuser.com/questions/187779/too-many-authentication-failures-for-username

This supposes that you are 192.168.20.9. Transfers between two remotes are harder: https://unix.stackexchange.com/questions/183504/how-to-rsync-files-between-two-remotes