1. 单向无密钥配置
station213 -> station220:步骤一:
输入命令: ssh-keygen 一路回车。。[root@station213 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)?
步骤二:
生成文件: id_rsa id_rsa.pub[root@station213 ~]# cd ~/.ssh/
[root@station213 .ssh]# ls
id_rsa id_rsa.pub known_hosts
步骤三:
拷贝文件:id_rsa.pub 到目标机器 station220,并改名为:authorized_keys[root@station213 .ssh]# scp id_rsa.pub 192.168.101.220:~/.ssh/authorized_keys
步骤四:
登录验证:没有提示输入密码,无密钥登录配置成功。[root@station213 .ssh]# ssh 192.168.101.220
Last login: Fri Mar 22 11:18:25 2013 from 192.168.101.213
[root@station220 ~]#
双向无密钥配置同上。。。
2. 多台机器间无密钥配置
举例如:station213 -> station220:station220 -> station213:
步骤一:
station213 -> station220:[root@station213 .ssh]# ssh-copy-id -i id_rsa.pub root@192.168.101.220
10
Now try logging into the machine, with "ssh 'root@192.168.101.220'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[root@station213 .ssh]# ssh-copy-id -i id_rsa.pub root@192.168.101.220
10
root@192.168.101.220's password:
Now try logging into the machine, with "ssh 'root@192.168.101.220'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[root@station213 .ssh]# ssh 192.168.101.220
Last login: Fri Mar 22 11:30:05 2013 from 192.168.101.213
[root@station220 ~]#