友情提示:
如果需要实现xshell 等终端工具实现免密码登陆的,在生成密钥对的时候,务必先把id_rsa就拷贝出来,不然到时候你配置好了的时候,通过xftp等工具拷贝文件出来,发现本地没有密钥文件,到时候就是死循环了。切记切记!!
[root@localhost ~]# ssh-keygen Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): Created directory ‘/root/.ssh‘.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:92:98:a4:6d:a3:bf:04:67:f5:5f:d9:e2:9f:e1:b8:c1 root@localhost.localdomainThe key‘s randomart image is:+--[ RSA 2048]----+| || || . . || + + o o || o O o S + . || * . . . + . || . . . E . || o = o || o. o.+ |+-----------------+[root@localhost ~]#
[root@localhost .ssh]# cd /root/.ssh/[root@localhost .ssh]# cat id_rsa.pub >authorized_keys
[root@localhost .ssh]# chmod 600 authorized_keys
[root@localhost .ssh]# vi /etc/ssh/sshd_config RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keysPasswordAuthentication no
[root@localhost .ssh]# service sshd restartStopping sshd: [ OK ]Starting sshd: [ OK ][root@localhost .ssh]#
最后拷贝is_rsa 到任意地方保存即可实行无密码登陆
本文出自 “9462880” 博客,请务必保留此出处http://9472880.blog.51cto.com/9462880/1771312
原文地址:http://9472880.blog.51cto.com/9462880/1771312