0

Hi there is a bunch of videos and resources on how to rsync locally rsync /home/user1 /home/user2/backup, but i haven't found any tutorials on rsync crontab to another server

pretty much, i use crontab -e and i have a script i run from rsynch.sh

#!/bin/bash
rsync -xza /home/willchap  willchap@server02:/home/willchap/backup

it will work fine without crontab, the problem is, i am guessing crontab fails because it is asking for a password

what are my options here?

SDsolar
  • 3,219
user2805313
  • 337
  • 2
  • 5
  • 8

2 Answers2

4

The best option, if you can, is to set up key-based SSH authentication on the remote server, and use a key with no passphrase on the client. This will allow the SSH connection, which rsync uses when you use that [user@]server:path notation, to happen without prompting for a password.

Ubuntu documentation for doing this is at:

https://help.ubuntu.com/community/SSH/OpenSSH/Keys#Key-Based_SSH_Logins

Once set up, try to SSH to the remote server from and to the same accounts that rsync would use, and see if it asks for a password. If it doesn't, it's set up correctly.

thomasrutter
  • 37,804
0

actually, yes it is possible.

do your normal rsyncscript.sh you will need to generate keys using the command ssh-keygen

in your home directory, go to .ssh/id_rsa.pub and copy that into the other servers /authorized_keys file

user2805313
  • 337
  • 2
  • 5
  • 8