两台主机
主机名: ha1 IP:192.168.104.11
主机名: ha2 IP:192.168.104.12
在ha1 ha2上生成key 文件
[root@ha1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:
71:7b:44:04:a4:31:6d:86:7e:c4:f3:e0:e7:62:e1:db root@ha1
[root@ha1 ~]#
Created directory '/root/.ssh'.
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:
71:7b:44:04:a4:31:6d:86:7e:c4:f3:e0:e7:62:e1:db root@ha1
[root@ha1 ~]#
[root@ha2 .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:
2b:72:bb:88:99:71:73:ce:ab:1e:56:3a:55:c3:e6:12 root@ha2
[root@ha2 .ssh]#
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:
2b:72:bb:88:99:71:73:ce:ab:1e:56:3a:55:c3:e6:12 root@ha2
[root@ha2 .ssh]#
将ha1 的id_rsa_pub 文件拷贝到ha2 上
[root@ha1 .ssh]# scp id_rsa.pub root@ha2:/root/.ssh/authorized_keys
The authenticity of host 'ha2 (192.168.104.12)' can't be established.
RSA key fingerprint is 6c:9a:36:ae:76:22:82:a6:44:ba:1f:86:36:7d:1e:d3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ha2,192.168.104.12' (RSA) to the list of known hosts.
root@ha2's password:
id_rsa.pub 100% 390 0.4KB/s 00:00
[root@ha1 .ssh]# ssh root@ha2
Last login: Mon Oct 31 05:39:26 2011 from ha1
The authenticity of host 'ha2 (192.168.104.12)' can't be established.
RSA key fingerprint is 6c:9a:36:ae:76:22:82:a6:44:ba:1f:86:36:7d:1e:d3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ha2,192.168.104.12' (RSA) to the list of known hosts.
root@ha2's password:
id_rsa.pub 100% 390 0.4KB/s 00:00
[root@ha1 .ssh]# ssh root@ha2
Last login: Mon Oct 31 05:39:26 2011 from ha1
此时ha1 不用密码可登陆到ha2
将ha2 的id_rsa_pub 文件拷贝到ha1上
[root@ha2 .ssh]# scp id_rsa.pub root@ha1:/root/.ssh/authorized_keys
The authenticity of host 'ha1 (192.168.104.11)' can't be established.
RSA key fingerprint is ab:8a:5c:c2:82:88:24:8c:e2:30:5c:c8:91:63:d6:02.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ha1,192.168.104.11' (RSA) to the list of known hosts.
root@ha1's password:
id_rsa.pub 100% 390 0.4KB/s 00:00
[root@ha2 .ssh]# ssh root@ha1
Last login: Mon Oct 31 21:58:31 2011 from ha2
The authenticity of host 'ha1 (192.168.104.11)' can't be established.
RSA key fingerprint is ab:8a:5c:c2:82:88:24:8c:e2:30:5c:c8:91:63:d6:02.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ha1,192.168.104.11' (RSA) to the list of known hosts.
root@ha1's password:
id_rsa.pub 100% 390 0.4KB/s 00:00
[root@ha2 .ssh]# ssh root@ha1
Last login: Mon Oct 31 21:58:31 2011 from ha2
此时可在ha2 无密码的ssh 到ha1 上
没有评论:
发表评论