目录(?)[+]

1. 单向无密钥配置

station213 -> station220:

步骤一:

输入命令: ssh-keygen 一路回车。。

[python] view plain copy

  1. [root@station213 ~]# ssh-keygen   

  2. Generating public/private rsa key pair.  

  3. Enter file in which to save the key (/root/.ssh/id_rsa):   

  4. /root/.ssh/id_rsa already exists.  

  5. Overwrite (y/n)?   

步骤二:

生成文件: id_rsa  id_rsa.pub

[python] view plain copy

  1. [root@station213 ~]# cd ~/.ssh/  

  2. [root@station213 .ssh]# ls  

  3. id_rsa  id_rsa.pub  known_hosts  

步骤三:

拷贝文件:id_rsa.pub 到目标机器 station220,并改名为:authorized_keys

[python] view plain copy

  1. [root@station213 .ssh]# scp id_rsa.pub 192.168.101.220:~/.ssh/authorized_keys  

步骤四:

登录验证:没有提示输入密码,无密钥登录配置成功。

[python] view plain copy

  1. [root@station213 .ssh]# ssh 192.168.101.220  

  2. Last login: Fri Mar 22 11:18:25 2013 from 192.168.101.213  

  3. [root@station220 ~]  


双向无密钥配置同上。。。

2. 多台机器间无密钥配置

举例如:station213 -> station220:

                station220 -> station213:

步骤一:

station213 -> station220:

[python] view plain copy

  1. [root@station213 .ssh]# ssh-copy-id -i id_rsa.pub root@192.168.101.220  

  2. 10  

  3. Now try logging into the machine, with "ssh 'root@192.168.101.220'"and check in:  

  4.   

  5.   

  6.   .ssh/authorized_keys  

  7.   

  8.   

  9. to make sure we haven't added extra keys that you weren't expecting.  

  10.   

  11.   

  12. [root@station213 .ssh]# ssh-copy-id -i id_rsa.pub root@192.168.101.220  

  13. 10  

  14. root@192.168.101.220's password:   

  15. Now try logging into the machine, with "ssh 'root@192.168.101.220'"and check in:  

  16.   

  17.   

  18.   .ssh/authorized_keys  

  19.   

  20.   

  21. to make sure we haven't added extra keys that you weren't expecting.  

  22.   

  23.   

  24. [root@station213 .ssh]# ssh 192.168.101.220  

  25. Last login: Fri Mar 22 11:30:05 2013 from 192.168.101.213  

  26. [root@station220 ~]  


步骤二:

station213 -> station221:同上。。



转自:http://blog.csdn.net/robertkun/article/details/8705535