配置密钥的步骤:(其实不是很复杂,只是难者不会,会者不难而已)
1、首先清空当前用户目录下的.ssh目录:
[oracle@racpub1 oracle]$ mv .ssh .ssh_bak
2、在两台机器上都生成公钥和密钥文件:(注意这个步骤是要在两台机器上都做的)
[oracle@racpub1 oracle]$ ssh-keygen -t dsa -b 1024
Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa):
Created directory '/home/oracle/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_dsa.
Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
7f:3a:5f:a6:43:37:d4:9a:8e:47:47:41:ff:d6:e1:7b oracle@racpub1
3、将公钥传到另一台机器上,和自己的机器上的authorized_keys这个文件中,同样是两台机器都要执行的。这一次是需要录入口令的。
[oracle@racpub1 oracle]$ ssh racpub1 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
The authenticity of host 'racpub1 (*.*.*.*)' can't be established.
RSA key fingerprint is 46:33:4f:d8:95:82:d9:93:53:4f:61:51:66:45:15:81.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'racpub1,*.*.*.*' (RSA) to the list of known hosts.
oracle@racpub1's password:
[oracle@racpub1 oracle]$ ssh racpub2 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
The authenticity of host 'racpub2 (*.*.*.*)' can't be established.
RSA key fingerprint is 74:23:59:44:b8:9c:bf:31:17:71:40:e5:d4:09:e7:5f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'racpub2,*.*.*.*' (RSA) to the list of known hosts.
4、校验正确完成。
[oracle@racpub1 oracle]$ ssh racprv1 hostname
racpub1
[oracle@racpub1 oracle]$ ssh racprv2 hostname
racpub2
来自 “ ITPUB博客 ” ,链接:/,如需转载,请注明出处,否则将追究法律责任。
转载于:/
本文发布于:2024-01-30 18:41:33,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170661129422049.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |