首页 > 其他 > 详细

centos/redhat 7 配置ssh免密登陆

时间:2019-11-22 14:41:16      阅读:81      评论:0      收藏:0      [点我收藏+]

1、确保本地local_host和远程remote_host都安装了openssh

2、local_host创建ssh密钥对:ssh-keygen -t rsa, 然后一路enter

3、remote_host创建.ssh目录和authorized_keys文件,然后修改权限

mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
 

4、将local_host创建的公钥rsa_rsa.pub传到remote_host的authorized_keys里面。可通过scp:

scp ~/.ssh/id_rsa.pub username@remote_host:~/.ssh/authorized_keys

也可通过ssh-copy-id命令(建议):

ssh-copy-id username@remote_host

5、ssh-copy-id执行成功后即可在本地主机上使用ssh免密登陆远程主机。之后可以禁用远程主机的密码登陆:

vim /etc/ssh/sshd_config

修改这一行为 no

PasswordAuthentication yes

PasswordAuthentication no

 

centos/redhat 7 配置ssh免密登陆

原文:https://www.cnblogs.com/ValyrianSteel/p/11910957.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!