首先建立本机的公私密钥
CODE
[root@host1 root]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
9b:40:4c:a1:9c:d0:10:d6:bf:1b:5f:0d:8c:6b:0c:0a root@host1
[root@host1 root]#
注意不要输入passphrase
然后将公钥文件传送到需要登陆的服务器
CODE
[root@host1 root]# scp .ssh/id_dsa.pub root@host2:id_dsa.pub
root@host2.verycd.com's password:
id_dsa.pub 100% |*****************************| 600 00:00
登陆那台服务器
CODE
[root@host1 root]# ssh -v root@host2
将刚才的公钥文件内容添加到用户的.ssh目录下的authorized_keys文件中
CODE
[root@host2 root]# cat id_dsa.pub >> /root/.ssh/authorized_keys
然后更改该文件权限
CODE
[root@host2 root]# chmod 600 /root/.ssh/authorized_keys
退出
CODE
[root@host2 root]# exit
Connection to host2 closed.
[root@host1 root]#
再次登陆即不再需要密码了
CODE
[root@host1 root]# ssh host2
Last login: Wed Nov 17 17:55:34 2004 from 61.129.xxx.xxx
[root@host2 root]#
motd file=/etc/rsyncd.motd
read only=yes
list=yes
uid=root
gid=root
use chroot=no
max connections=3
log file=/var/log/rsyncd.log
pid file=/var/log/rsyncd.pid
lock file=/var/run/rsync.lock
[share]
comment=share file
path=/home/www
v是verbose,
z是压缩,
r是recursive,
topg都是保持文件原有属性如属主、时间的参数
--progress 是指显示出详细的进度情况
--delete 是指如果服务器端删除了这一文件,那么客户端也相应把文件删除,保持真正的一致