(一) SSH的配置
1,确认系统已经安装好OpenSSH的server 和client
2,确认本机sshd的配置文件
[root@wwy ~]# vi /etc/ssh/sshd_config
找到以下内容,并去掉注释符”#“
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
3,重启sshd服务
[root@wwy ~]# /sbin/service sshd restart
4,ssh登陆
[root@wwy ~]# ssh localhost
(二) 生成公私钥以及应用
1,生成公私钥
[root@wwy ~]# ssh-keygen -t rsa
一直按回车键,直到结束
其中rsa为文件名,生成的文件在/root/.ssh/ 目录下
2,添加公钥到权限文件
[root@wwy ~]# cat id_rsa.pub >> authorized_keys
3,或者使用以下命令
[root@wwy ~]# ssh-keygen -t dsa -P ” -f ~/.ssh/id_dsa
[root@wwy ~]# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
4,将生成的公钥拷贝到另一台主机的root目录下
[root@wwy ~]# scp id_rsa.pub wwy02:/root
注意修改权限
chmod 600 authorized_keys或直接用命令
[wwy@wwy01 ~]$ ssh-copy-id wwy02