Linux(CentOS)免密码SSH登录
这次的重点在于SSH免密码登录,直面主题,以最简单的环境进行考虑————同网段的两个ip之间SSH免密码登录。
策略:
PC-a主机想要免密码SSH登录PC-b主机,那么采用非对称加密,生成一对密钥(私钥------公钥),在PC-a主机生成一对密钥,把公钥复制一份放到PC-b。
同理,PC-b想要免密码SSH登录PC-a,就在PC-b主机生成一对密钥,把公钥复制一份,放到PC-a。
两台电脑ip分别为:192.168.8.88 、192.168.8.99
1.初始状态
(1)未配置前,192.168.8.88 ssh登录 192.168.8.99 :需要输密码
[root@wqb88 ~]# ssh 192.168.8.99
root@192.168.8.99's password:
Last login: Wed Sep 21 01:11:16 2016 from wqb88
(2)未配置前,192.168.8.99 ssh登录 192.168.8.88 :需要输密码
[root@wqb99 ~]# ssh 192.168.8.88
root@192.168.8.88's password:
Last login: Wed Sep 21 01:14:20 2016 from wqb992.生成 密码对
[root@wqb99 .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
64:19:b6:71:19:f7:b8:1a:66:de:cb:5c:e3:05:dc:bb root@wqb99
The key's randomart image is:
+--[ RSA 2048]----+
| + oo. |
| . *.. o |
| = . . |
| o o . |
| S + . o .|
| + + ..|
| o . o..|
| o + o.|
| + .E |
+-----------------+
3.复制 公钥到 想要去登录主机
[root@wqb88 ~]# ssh-copy-id 192.168.8.994.免密码登录成功
[root@wqb88 ~]# ssh 192.168.8.99
Last login: Wed Sep 21 01:14:07 2016 from wqb88
本文介绍如何在两台CentOS系统之间实现SSH免密码登录。通过生成非对称密钥对并在目标主机上放置公钥来实现。适用于同一网段内的主机之间的安全连接。
1976





