LINUX配置双机SSH信认,并用public key认证登录

http://blog.itpub.net/15693674/viewspace-767572/

[oracle@vrh1 .ssh]$ cat id_dsa.pub  >> authorized_keys               
#将本机vrh1上的dsa保存到授权文件中
[oracle@vrh1 .ssh]$ cat id_rsa.pub  >> authorized_keys               
#将本机vrh1上的rsa保存到授权文件中
[oracle@vrh1 .ssh]$ ssh vrh2 cat ~/.ssh/id_dsa.pub >> authorized_keys
#将vrh2上的dsa保存到授权文件中

Linux Server1:192.168.1.104
Linux Server2:192.168.1.105
终端:SSH Secure Shell Client

1.用password方式登录Linux Server1和2

2.在Linux Server1上命令操作如下:两台服务器都要输入
#ssh-keygen -t dsa
并三次回车

#cd .ssh/
#cp id_dsa.pub authorized_keys
#chmod 600 authorized_keys
#scp -P22 * [email protected]:/root/.ssh

报错:RSA host key for mysharebook.cn has changed and you have requested strict checking.
Host key verification failed.
解决方法:
这是Linux重装或则openssh-server重装引起的,执行以下命令即可
ssh-keygen -R 192.168.87.36  192.168.87.36换成你要连的服务器就可以了。


其中在scp的时候 会提示Are you sure you want to continue connecting (yes/no)?
确定输入yes进行确认,之后会提示[email protected]′s password: 要求输入root密码
我们在Linux Server1(192.168.1.104)上ssh连接Linux Server2(192.168.1.105),看下是否正常
#ssh 192.168.1.105

然后在Linux Server2(192.168.1.105)上ssh连接Linux Server1(192.168.1.104),看下是否正常
如果提示:Are you sure you want to continue connecting (yes/no)? 输入yes即可
到目前为止 已经配置好Linux Server1和Linux Server2的SSH互相信任,SSH连接并不需要密码

猜你喜欢

转载自liuwanxiang.iteye.com/blog/1494127