本文主要是介绍通过两台linux主机配置ssh实现互相免密登入,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一
1.使用Xshell远程连接工工具生成公钥文件

2.生产密钥参数
3.生成公钥对
4.用户密钥信息
5.公钥注册
二
1.关闭服务端防火墙
---systemctl stop firewalld
2.检查是否有/root/.ssh目录,没有则创建有则打开/root/.ssh/authorized_keys文件将密钥粘贴
创建/root/.ssh目录:
sudo mkdir -p /root/.ssh
创建/root/.ssh/authorized_keys文件:
sudo touch /root/.ssh/authorized_keys
打开/root/.ssh/authorized_keys文件并粘贴密钥:
vim /root/.ssh/authorized_keys
密钥:
3.在客户端,使用“ssh-keygen -t rsa -b 2048”命令生成密钥文件---ssh-keygen -t rsa -b 2048
4.在客户端使用 “ssh-copy-id -i root@服务端IP”将密钥文件拷贝给服务端,并输入一次服务器端密码---ssh-copy-id -i root@服务端IP
5.测试是否能够免密登录,“ssh 用户名@目标IP”---ssh root@服务端IP
6.关闭客户端防火墙
systemctl stop firewalld #关闭防火墙
systemctl status firewalld #查看防火墙状态
7.创建/root/.ssh/authorized_key1文件---sudo touch /root/.ssh/authorized_keys1
8.将密钥复制粘贴至文件/root/.ssh/authorized_key1---vim /root/.ssh/quthorized_key1 #打开文件
9.在服务端,使用“ssh-keygen -t rsa -b 2048”命令生成密钥文件---ssh-keygen -t rsa -b 2048
10.在客户端使用 “ssh-copy-id -i root@服务端IP”将密钥文件拷贝给服务端,并输入一次服务器端密码---ssh-copy-id -i root@服务端IP
11.测试是否能够免密登录,“ssh 用户名@目标IP”---ssh root@目标IP
最后便成功通过两台linux主机配置ssh实现互相免密登入!!
这篇关于通过两台linux主机配置ssh实现互相免密登入的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!