[iyunv@rhel6 ~]# ssh-keygen -t rsa //创建密钥对
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): //回车
Enter passphrase (empty for no passphrase): //回车
Enter same passphrase again: //回车
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
2c:56:1d:bf:af:82:69:4c:19:56:5a:18:7e:af:41:24 root@rhel5
[iyunv@rhel6 ~]# ssh-copy-id root@192.168.130.133 //将公钥发给服务器 root@192.168.130.133's password: //输入密码
Now try logging into the machine, with "ssh 'root@192.168.130.133'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[iyunv@localhost 桌面]# ssh root@192.168.130.123 //不用密码登录
Last login: Sun Jan 25 10:57:48 2015 from 192.168.130.133
[iyunv@rhel6 ~]#
测试远程备份。
1
2
[iyunv@rhel6 ~]# ll /wwwroot/
total 0
在服务器上创建/var/www/html/test文件。
1
[iyunv@localhost 桌面]# touch /var/www/html/test
回到客户机上同步服务器
1
2
3
4
5
6
7
8
9
[iyunv@rhel6 ~]#rsync -avz root@192.168.130.133:/var/www/html /wwwroot/
receiving incremental file list
./
test
sent 33 bytes received 83 bytes 232.00 bytes/sec
total size is 0 speedup is 0.00
[iyunv@rhel6 ~]#ll /wwwroot/
total 0
-rw-r--r-- 1 root root 0 Jan 25 11:16 test
[iyunv@localhost ~]# tar zxf inotify-tools-3.14.tar.gz
[iyunv@localhost ~]# cd inotify-tools-3.14
[iyunv@localhost inotify-tools-3.14]# ./configure && make && make install