假如你想从A机器登录到B机器,具体步骤如下:
1.登录到A机器
# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
82:0c:91:f4:61:d0:03:52:e0:86:6a:66:77:f7:d0:40 root@mingban.waptx.com
出现的提示直接回车,不需理会,这样会在/root/.ssh/目录下产生两个文件:id_dsa id_dsa.pub
id_dsa 密钥文件
id_dsa.pub 公钥文件,这个文件需要复制到B机器的/root/.ssh/authorized_keys文件中
2.将密钥文件复制到identity文件中
# cd /root/.ssh/
# cat id_dsa > identity
# chmod 600 identity
2.将公钥文件复制到B机器的/roo/.ssh/authorized_keys文件中
# cd /root/.ssh
# scp id_dsa.pub root@B:/root/.ssh/authorized_keys
注意:要保证B机器的/etc/ssh/sshd_config文件中有
RSAAuthentication yes
这样就可以不需要输入密码就可以从A机器登录到B机器了.
阅读(1015) | 评论(0) | 转发(0) |