配置ssh免密碼登錄步驟,Linux ssh 不需要輸入密碼的方法

 2023-12-06 阅读 25 评论 0

摘要:采用證書的方法可以解決ssh不需要輸入密碼的問題。 配置ssh免密碼登錄步驟、本文采用CentOS的操作系統,創建SSH的key,并在兩臺或多臺機器間實現信任。從而實現SSH登錄不需要輸入密碼的功能。 首先,在一臺機器上創建SSH Key: [root@mysql-ha2

采用證書的方法可以解決ssh不需要輸入密碼的問題。

配置ssh免密碼登錄步驟、本文采用CentOS的操作系統,創建SSH的key,并在兩臺或多臺機器間實現信任。從而實現SSH登錄不需要輸入密碼的功能。

首先,在一臺機器上創建SSH Key:

[root@mysql-ha2 ~]# ssh-keygen?

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):?

Created directory '/root/.ssh'.

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:

e1:9b:9a:b8:4d:ea:2c:e7:0c:49:bd:a7:47:fa:b4:4b root@mysql-ha2

The key's randomart image is:

+--[ RSA 2048]----+

| ? ? ? ? ? ? ? ? |

| ? ? ? ? ? ? ? ? |

|? ? ? ? .? ? ? ? |

| ? . ? . . ? ? ? |

|? . . ? S? ? ? ? |

| . . ..? o ? ? ? |

|? o .oE o? ? ? ? |

|? .+oX.+ ? ? ? ? |

| ? =X+B. ? ? ? ? |

+-----------------+

此時可以在/root/.ssh目錄下看到兩個文件:

-rw-------. 1 root root 1675 Dec? 5 05:02 id_rsa

-rw-r--r--. 1 root root? 396 Dec? 5 05:02 id_rsa.pub

復制Key到另外一臺機器上,使登錄這臺機器不輸入密碼:

[root@mysql-ha2 .ssh]# ssh-copy-id -i id_rsa.pub root@10.1.1.4

測試,發現登錄ssh 10.1.1.4不需要密碼。

?

把id_rsa和id_rsa.pub復制到10.1.1.4上,在10.1.1.4上做同樣的ssh-copy-id的動作,可以使雙向ssh登錄不需要密碼。

?

且采用的是相同的ssh key。

轉載于:https://www.cnblogs.com/hengwei/p/5021411.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/3/192310.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息