本博客已遷往http://coredumper.cn
兩臺主機均爲 CentOS
系統,主機名分別爲 node0
和 node1,node0
的 IP
爲 10.141.4.36,node1
的 IP
爲 10.141.4.39,兩臺主機均使用用戶名
cluster。
1. 在
node0 和
node1 上進行如下操作:
在/etc/hosts
文件中添加如下內容:
10.141.4.36 node0
10.141.4.39 node1
在/home/cluster
目錄下執行如下命令,生成.ssh
目錄:
ssh-keygen -t rsa
2. 在
node1 的/home/cluster/.ssh
目錄下執行如下命令:
scp node0:/home/cluster/.ssh/id_rsa.pub /home/cluster/.ssh/tmp
cat tmp >> authorized_keys
chmod 600 authorized_keys
rm tmp
修改文件/etc/ssh/sshd_config,去掉對如下三行的註釋:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
此時可以從 node0 無密碼登錄到 node1 了。
3. 在 node0 的/home/cluster/.ssh 目錄下執行如下命令:
scp node1:/home/cluster/.ssh/id_rsa.pub /home/cluster/.ssh/tmp
cat tmp >> authorized_keys
chmod 600 authorized_keys
rm tmp
修改文件/etc/ssh/sshd_config,去掉對如下三行的註釋:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
此時可以從 node1 無密碼登錄到 node0 了。
4. 檢查 node0 和 node1 是否可以無需密碼而直接互相登錄:
ssh node0
ssh node1