环境:本地主机:ha01eth0: 192.168.1.100 //对外IP地址 远程主机:ha02eth0: 192.168.1.200 //对外IP地址 本地主机ha01配置: [root@ha01 /
环境:
本地主机:ha01
eth0: 192.168.1.100 //对外IP地址
远程主机:ha02
eth0: 192.168.1.200 //对外IP地址
本地主机ha01配置:
[root@ha01 /]# cd /etc/ssh
[root@ha01 ssh]# ssh-keygen -t rsa -N "" (该步骤生成key公私密钥对,-N ""表示密钥对短语为空)
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:
82:2c:74:43:8e:16:f4:ef:ac:91:0f:d7:6f:a6:f3:59 root@ha01
复制公共密钥到远程主机(原始方法):
若ha02服务器上/root/.ssh/authorized_keys文件不存在
[root@ha01 ssh]# scp /root/.ssh/id_rsa.pub root@192.168.1.200:/root/.ssh/authorized_keys
若authorized_keys文件存在
ha01上执行:
[root@ha01 ssh]# scp /root/.ssh/id_rsa.pub root@192.168.1.200:/root/.ssh/
ha02上执行:
[root@ha02 /]# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
复制公共密钥到远程主机(新方法):
可以使用ssh-copy-id方便安全的将公共密钥复制到远程主机
ha01上执行:
[root@ha01 ssh]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.200
SSH登录测试:
[root@ha01 ssh]# ssh ha02
Last login: Fri Apr 8 10:41:28 2011 from ha01
--结束END--
本文标题: ssh(ssh-keygen)配置免输入密码登录远程主机的方法
本文链接: https://www.lsjlt.com/news/18098.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-18
2024-04-17
2024-04-11
2024-04-08
2024-04-08
2024-04-03
2024-03-15
2024-03-15
2024-03-11
2024-03-08
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0