Linux 添加ssh公钥 实现免密认证

时间:2024-03-27 17:37:46

ssh 无密码登录要使用公钥与私钥。linux下可以用用ssh-******生成公钥/私钥对

1.添加A服务器公钥到B服务器

2.到A服务器输入命令ssh-******  一路回车

Linux 添加ssh公钥 实现免密认证

 3.找到A服务器的/root/.ssh/id_rsa.pub 打开复制内容

4.找到B服务器的/root/.ssh/authorized_keys 将A服务器的id_rsa.pub公钥内容复制进去即可

或者使用命令

##在A服务器上执行
scp /root/.ssh/id_rsa.pub [email protected]:/root/.ssh/authorized_keys