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:
24:cb:cb:9f:29:48:60:fc:b2:a6:93:0a:f8:00:6f:60 root@test3.yuhang.gov.cn
[root@test3 .ssh]# scp ~/.ssh/id_dsa.pub 10.32.184.234:~/.ssh/
root@10.32.184.234's password:
id_dsa.pub 100% 614 0.6KB/s 00:00
[root@test3 .ssh]# ssh 10.32.184.234
root@10.32.184.234's password:
Last login: Sat Jan 2 16:07:32 2010 from 10.32.184.233
[root@test4 ~]# cd .ssh/
[root@test4 .ssh]# ls
authorized_keys id_dsa.pub id_rsa id_rsa.pub known_hosts
[root@test4 .ssh]# cat id_dsa.pub >authorized_keys
[root@test4 .ssh]# exit
logout
Connection to 10.32.184.234 closed.
[root@test3 .ssh]# ssh 10.32.184.234
Last login: Sat Jan 2 16:08:59 2010 from 10.32.184.233
[root@test4 ~]#
[root@test4 ~]# exit
logout
Connection to 10.32.184.234 closed.
[root@test3 .ssh]# 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:
b4:6a:da:19:b7:62:5a:8c:8c:b0:75:a9:b9:40:09:7e root@test3.yuhang.gov.cn
[root@test3 .ssh]# scp ~/.ssh/id_rsa.pub 10.32.184.234:~/
[root@test3 .ssh]# ls
id_dsa id_dsa.pub id_rsa id_rsa.pub known_hosts
[root@test3 .ssh]# scp ~/.ssh/id_rsa.pub 10.32.184.234:~/
root@10.32.184.234's password:
id_rsa.pub 100% 406 0.4KB/s 00:00
[root@test3 .ssh]# ssh 10.32.184.234
root@10.32.184.234's password:
Last login: Sat Jan 2 16:09:43 2010 from 10.32.184.233
[root@test4 ~]# cp ~/id_rsa.pub ~/.ssh/authorized_keys
cp:是否覆盖“/root/.ssh/authorized_keys”? y
[root@test4 ~]#
logout
Connection to 10.32.184.234 closed.
[root@test3 .ssh]# ssh 10.32.184.234
Last login: Sat Jan 2 16:13:25 2010 from 10.32.184.233
[root@test4 ~]#
The authenticity of host '10.32.184.232 (10.32.184.232)' can't be established.
RSA key fingerprint is 60:19:ce:e5:82:ff:aa:04:d5:a3:0c:36:40:bf:e3:51.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.32.184.232' (RSA) to the list of known hosts.
root@10.32.184.232's password:
Last login: Fri Jan 1 17:59:43 2010 from test0.yuhang.gov.cn
[root@test2 ~]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Created directory '/root/.ssh'.
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:
55:f9:02:15:b8:5e:3b:37:dd:0b:57:1e:b8:21:18:d5 root@test2.yuhang.gov.cn
[root@test2 ~]# scp .ssh/id_dsa.pub 10.32.184.234:~/
The authenticity of host '10.32.184.234 (10.32.184.234)' can't be established.
RSA key fingerprint is 60:19:ce:e5:82:ff:aa:04:d5:a3:0c:36:40:bf:e3:51.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.32.184.234' (RSA) to the list of known hosts.
root@10.32.184.234's password:
id_dsa.pub 100% 614 0.6KB/s 00:00
[root@test2 ~]# ssh 10.32.184.234
root@10.32.184.234's password:
Last login: Sat Jan 2 16:14:42 2010 from 10.32.184.233
[root@test4 ~]# cat id_dsa.pub >> ~/.ssh/authorized_keys
[root@test4 ~]# exit
logout
Connection to 10.32.184.234 closed.
[root@test2 ~]# ssh 10.32.184.234
Last login: Sat Jan 2 16:21:25 2010 from 10.32.184.232
[root@test4 ~]#
完成这些工作后,用户从本地机器到远程机器的登录就不用密码了.
该设置简单实用.