配置密钥的步骤

  • Post author:
  • Post category:其他



配置密钥的步骤:(其实不是很复杂,只是难者不会,会者不难而已)



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博客 ” ,链接:http://blog.itpub.net/51862/viewspace-180544/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/51862/viewspace-180544/