ssh 免登陸配置
阿新 • • 發佈:2018-11-12
在配置Hadoop叢集分佈時,要使用SSH免密碼登入,假設現在有兩臺機器[email protected](192.168.10.100),作為A機,[email protected](192.168.10.107),作為B機。現想[email protected]通過ssh免密碼登入到[email protected]。
1.在A機下生成公鑰/私鑰對。
敲擊回車鍵即可,
它在/home/hadoop下生成.ssh目錄,.ssh下有id_rsa和id_rsa.pub。
2.把A機器下的id_rsa.pub複製到B機器下的.ssh/authorized_keys檔案裡。
第一次登入是時要你輸入yes。
現在A機可以無密碼登入B機了。
小結:登入的機子可有私鑰,被登入的機子要有登入機子的公鑰。這個公鑰/私鑰對一般在私鑰宿主機產生。上面是用rsa演算法的公鑰/私鑰對,當然也可以用dsa(對應的檔案是id_dsa,id_dsa.pub)
想讓A,B機無密碼互登入,那B機以上面同樣的方式配置即可,把B的公鑰複製過去新增到authorized_keys的末尾就行了。
1.在A機下生成公鑰/私鑰對。
[[email protected] ~]$ ssh-keygen -t rsa -P ''
|
它在/home/hadoop下生成.ssh目錄,.ssh下有id_rsa和id_rsa.pub。
2.把A機器下的id_rsa.pub複製到B機器下的.ssh/authorized_keys檔案裡。
[[email protected]
[email protected]'s password:
|
由於還沒有免密碼登入的,所以要輸入密碼。
[
[[email protected] ~]$ chmod 600 .ssh/authorized_keys
|
authorized_keys的許可權要是600。
[[email protected] ~]$ ssh 192.168.10.107
|
現在A機可以無密碼登入B機了。
小結:登入的機子可有私鑰,被登入的機子要有登入機子的公鑰。這個公鑰/私鑰對一般在私鑰宿主機產生。上面是用rsa演算法的公鑰/私鑰對,當然也可以用dsa(對應的檔案是id_dsa,id_dsa.pub)
想讓A,B機無密碼互登入,那B機以上面同樣的方式配置即可,把B的公鑰複製過去新增到authorized_keys的末尾就行了。