centos7設(shè)置機(jī)器間免密登錄

1.前言

為了降低服務(wù)器被侵入的風(fēng)險(xiǎn),大部分公司引入了跳板機(jī),跳板機(jī)可以在各個(gè)機(jī)器之間跳轉(zhuǎn),而每次輸入密碼是很繁瑣的,因此設(shè)置免密登錄是很有必要的。

2.配置

機(jī)器ip 機(jī)器用途
10.1.1.110 跳板機(jī)
10.1.1.1 目標(biāo)機(jī)器

以下操作均在跳板機(jī)執(zhí)行
生成rsa秘鑰 ssh-keygen -t rsa
將秘鑰復(fù)制到指定機(jī)器 ssh-copy-id root@10.1.1.1,此步需要輸入目標(biāo)機(jī)器id,成功提示如下:

[root@zhiaiyahong ~]# ssh-copy-id root@10.1.1.1
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@10.1.1.1's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@10.1.1.1'"
and check to make sure that only the key(s) you wanted were added.

直接ssh目標(biāo)機(jī)器即可登錄ssh 10.1.1.1

3.拓展

  • 集群
    只需要多次執(zhí)行 ssh-copy-id root@目標(biāo)機(jī)器 即可
  • 機(jī)器間互相登錄
機(jī)器ip 機(jī)器用途
10.1.1.2 主機(jī)1
10.1.1.3 主機(jī)2

主機(jī)1操作
生成rsa秘鑰 ssh-keygen -t rsa
將秘鑰復(fù)制到指定機(jī)器 ssh-copy-id root@10.1.1.3
主機(jī)2操作
生成rsa秘鑰 ssh-keygen -t rsa
將秘鑰復(fù)制到指定機(jī)器 ssh-copy-id root@10.1.1.2
即都生成秘鑰,并將秘鑰推送給對(duì)方,即可實(shí)現(xiàn)相互登錄

4.參考文章

本人在操作時(shí)未遇到問題,如遇到問題可查看此文章
centos7(3)之SSH配置方法以及集群機(jī)器之間SSH免密碼登錄

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容