備忘 CentOS 7 2 SSH免密登入

2021-07-11 05:54:35 字數 1187 閱讀 1722

1.編輯/etc/ssh/sshd_config,去掉以下3行的注釋,每台機器上均進行如此配置:

rsaauthentication yes

pubkeyauthentication yes

authorizedkeysfile  .ssh/authorized_keys

2.在192.168.1.221的hadoop使用者下,輸入「ssh-keygen -t rsa」生成公鑰

3.在192.168.1.222、192.168.1.223的hadoop使用者下,依次生成公鑰

4.在192.168.1.221上,/home/hadoop/.ssh目錄下,以使用者名稱hadoop執行:

cat id_rsa.pub>> authorized_keys

ssh [email protected] cat ~/.ssh/id_rsa.pub>>authorized_keys

ssh [email protected] cat ~/.ssh/id_rsa.pub>>authorized_keys

5.將authorized_key、known_hosts兩個檔案,從192.168.1.221上覆制到192.168.1.222、192.168.1.223上

scp authorized_key [email protected]:~/.ssh

scp authorized_key [email protected]:~/.ssh

scp known_hosts  [email protected]:~/.ssh

scp known_hosts  [email protected]:~/.ssh

6. 在192.168.1.221、222、223上以使用者名稱hadoop分別執行:

chmod 700 ~/.ssh

chmod 600 ~/.ssh/authorized_key 

7. 在192.168.1.221、222、223上以使用者名稱root分別執行:

systemctl restart sshd.service

8. 測試免密ssh登入,在192.168.1.221、222、223上以使用者名稱hadoop分別執行:

ssh [email protected]

ssh [email protected]

ssh [email protected]

[end]

CentOS配置SSH免密登入

生成公鑰命令 該賬號根目錄將下生成 ssh 目錄 ssh keygen t rsa 連續回車三次第一種方式 適合多台機器之間的快速配置ssh免密登入 ssh copy id i ssh id rsa.pub 機器ip id rsa.pub 公鑰 機器ip 需免密登入機器ip第二種方式 cd ssh ...

centos7ssh免密登入

在a上生成公鑰私鑰。將公鑰拷貝給server b,要重新命名成authorized keys 從英文名就知道含義了 將公鑰拷貝給server b,要重新命名成authorized keys 從英文名就知道含義了 server a向server b傳送乙個連線請求。server a向server b傳...

centos7 ssh免密登入

配置多台centos 機器 免密登入 用於搭建集群,redis,storm.現在有4臺機器 主機名分別是 eshop cache01 eshop cache02 eshop cache03 eshop cache04 1 首先在eshop cache02 eshop cache03 eshop ca...