最近在做hadoop,因為要求各主機之間的用戶必須相同,且為方便遠程登錄,需配置無密碼登錄
先附上ssh無密碼登錄設置方法:
先生成密鑰並配置無ssh無密碼登錄本機,輸入命令:
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
將文件拷貝到其他主機相同的文件夾內,輸入命令:
scp authorized_keys hostname1:~/.ssh/
scp authorized_keys hostname2:~/.ssh/
查看是否可以從主機無密碼登錄其他主機,輸入命令:
ssh hostname1
ssh hostname2
如果可以直接登錄,不需輸入密碼,則證明設置成功。
注:hostname1為其他主機的名字,在/etc/hosts中設置,格式為:xxx.xxx.xxx.xxx(IP地址) hostname1
不知道怎么搞的,后來連接的時候出現以下問題:
bobo@master:~$ ssh slave1
Warning: the ECDSA host key for 'slave1' differs from the key for the IP address '192.168.1.104'
Offending key for IP in /home/bobo/.ssh/known_hosts:5
Matching host key in /home/bobo/.ssh/known_hosts:2
Are you sure you want to continue connecting (yes/no)?
原因是knows_hosts中已經有了地址,將其清空,重新對各主機設置無密碼登錄(拷貝操作)。