Udgivet den

How to Setup Rsync with SSH on UNIX / Linux (rsync without password)

The following steps explains how to setup rsync over ssh that doesn’t ask for a password.
This is helpful when you are scheduling a cron job for automatic backup using rsync.

1. Test rsync over ssh (with password):

Do a rsync to make sure it asks for the password for your account on the remote server, and successfully copies the files to the remote server.

The following example will synchronize the local folder /home/pies to the remote folder /backup/pies (on 192.168.188.15 server).

This should ask you for the password of your account on the remote server.
rsync -avz -e ssh /home/pies/ pies@192.168.188.15:/backup/pies/

2. ssh-keygen generates keys.

Now setup ssh so that it doesn’t ask for password when you perform ssh. Use ssh-keygen on local server to generate public and private keys.
$ ssh-keygen
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

Note: When it asks you to enter the passphrase just press enter key, and do not give any password here.

3. ssh-copy-id copies public key to remote host

Use ssh-copy-id, to copy the public key to the remote host.
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.188.15
Note: The above will ask the password for your account on the remote host, and copy the public key automatically to the appropriate location.

4. Perform rsync over ssh without password

Now, you should be able to ssh to remote host without entering the password.
ssh 192.168.188.15
Perform the rsync again, it should not ask you to enter any password this time.
rsync -avz -e ssh /home/pies/ pies@192.168.188.15:/backup/pies/
If you want to schedule this rsync backup job automatically, use cron to set it up.

Udgivet den Skriv en kommentar

DNS nameserver and static IP, Ubuntu 14.04 LTS

sudo nano /etc/network/interfaces

and there

auto lo eth0
iface lo inet loopback
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1

If you are using ubuntu 14.04, you may find you can not setting dns on your /etc/resolv.conf
This is because ubuntu using resolvconf to manage the dns setting, every times system boot, resolvconf will regenerate resolv.conf file.
But there always have way to do this.
sudo gedit /etc/resolvconf/resolv.conf.d/base put your nameserver list in


nameserver 8.8.8.8
nameserver 8.8.4.4

then run

resolvconf -u

this command tell resolvconf to regenerate the resolve file