您的位置:首页 > 运维架构 > Linux

配置Linux 免密码登陆

2016-05-08 23:50 447 查看
配置Linux 免密码登陆
1 生成秘钥对,一路回车就好

2 修改公钥名称为authorized_keys

3 修改权限为600

4 修改sshd配置文件

5 重启sshd服务

配置Linux 免密码登陆

友情提示:
如果需要实现xshell 等终端工具实现免密码登陆的,在生成密钥对的时候,务必先把id_rsa就拷贝出来,不然到时候你配置好了的时候,通过xftp等工具拷贝文件出来,发现本地没有密钥文件,到时候就是死循环了。切记切记!!

1 生成秘钥对,一路回车就好

[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 ~]#

2 修改公钥名称为authorized_keys

[root@localhost .ssh]# cd /root/.ssh/[root@localhost .ssh]# cat id_rsa.pub >authorized_keys

3 修改权限为600

[root@localhost .ssh]# chmod 600 authorized_keys

4 修改sshd配置文件

[root@localhost .ssh]# vi /etc/ssh/sshd_config RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile      .ssh/authorized_keysPasswordAuthentication no

5 重启sshd服务

[root@localhost .ssh]# service sshd restartStopping sshd:                                             [  OK  ]Starting sshd:                                             [  OK  ][root@localhost .ssh]#
最后拷贝is_rsa 到任意地方保存即可实行无密码登陆
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux 配置 免密码