CentOS7 设置SSH免密钥登陆

CentOS7 设置SSH免密钥登陆

1 : 案例 有 服务器A和服务器B 现在 服务器A想要通过SSH免密钥登陆服务器B

1 配置ssh配置文件

vim /etc/ssh/sshd_config

PermitRootLogin yes
RSAAuthentication yes
PubkeyAuthentication yes 

将以上三个配置设置为 yes 然后重启ssh服务

#查看状态
systemctl status sshd.service
# 配置 ssh重启
systemctl enable sshd.service

2 在服务器A配置密钥

在这里插入图片描述

3 将生成的密钥拷贝到服务器B

ssh-copy-id -i ~/.ssh/id_rsa.pub root@服务器B的ip
#注意 -i 后面写的是密钥的绝对路径 不要写错

4 通过 ssh命令进行登陆

ssh 192.168.95.128  

猜你喜欢

转载自blog.csdn.net/dndndnnffj/article/details/109556753