hadoop 配置ssh免密码登录

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa

这里-t参数制定类型 -P 指定密码 ‘’表示为空 -f 表示生成的文件存放位置

cat ~/.ssh/id_rsa.pub  >> ~/.ssh/authorized_keys

将公钥追加到authorized_keys中

scott@master:~$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is 69:c4:9d:c0:04:ce:23:3a:79:43:9e:b9:32:22:ab:d2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.11.0-15-generic x86_64)

* Documentation: https://help.ubuntu.com/

Last login: Sun Mar 23 20:14:24 2014 from localhost
scott@master:~$

使用scp 将~/.ssh/authorized_keys拷贝到其他机器

scp /home/scott/.ssh/authorized_keys slave1:~/.ssh/
scp /home/scott/.ssh/authorized_keys slave2:~/.ssh/
scp /home/scott/.ssh/authorized_keys slave3:~/.ssh/

这样使用master分别登录slave1、slave2、slave3主机均可以免密码登录 反之不成

需要事先分别在slave1、slave2、slave3三台主机创建~/.ssh目录

为了安全期间记得设置authorized_keys文件权限为600 ~/.ssh目录权限为700