共计 1855 个字符,预计需要花费 5 分钟才能阅读完成。
批改域名与 IP 的对应关系(hadoop2 和 hadoop3 同样也须要批改 hosts 文件)
vi /etc/hosts
10.2.15.176 hadoop1
10.2.15.177 hadoop2
10.2.15.170 hadoop3
cd ~/.ssh
进入 rsa 公钥私钥文件寄存的目录 (如果没有.ssh 目录,则应用 ssh 命令连贯一次其余主机就会生成)
在 .ssh
目录下输出命令并三次回车就会生成 id_rsa
,id_rsa.pub
文件
ssh-keygen -t rsa
将 id_rsa.pub 公钥内容拷贝到 authorized_keys 文件中
cat id_rsa.pub >> authorized_keys
依照雷同的形式在另外两台服务器 hadoop2, hadoop3 生成 id_rsa.pub
,并把id_rsa.pub
拷贝到同一个 authorized_keys
文件中,拷贝后的authorized_keys
:
[root@hadoop1 .ssh] more authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC92MPpDY5H4Rnq9AM1QKPFu6dRlLI2oiH/C+eUtDcYM4TQMLV9/Jwk0ffOaWvGIdLYbj/pQ+pZm8i4jWXQ/IDtnC8UlScQqpa5dkzi3yBZTs6/t6Z5+Hbe0s8cXemqxXllVIitg3VQQ8hZOQss5kl/XS4mN51xAfCnuehr1VLOJ3eMjmoIpKtWSzypxaO7GTxHfd/zzZB0fs5u//Sv1uaZKpIHPWCFiNvfxDG4C1mts9LqIf+iQyMrJGCCFxuuIOGvBjqmNDX2dUd7glVCwpiQf2bbw1N7INvfOkwoT33hSn0uICGvK36tQYYh8CAyyuh9CUP+TJu+Mz0M0fcNeJ root@hadoop1.com
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDX8gcUU5M8RURsxBfSzrdMTjXxJAU6UsxLHLxxCa1aiUNrLQyF6QwwZQlmzBpnNjXE9vOtzTfXOAu7m/2YBXDN8tQ4ULFNmKF3xt/lZfeYkSiuJmSxOw/BklOJGhwrEwJIaQV7h28Oqx/o2iHyfSbx6BcBDVzzwiwBlKThb3EM9J3r9dHynvT0ogGb5KpP/o4pi7inhb7PffB5zq4sz1Q726tq9YsS/uG3emJLHj4ovSf4F3FIFPY8mtFuTsIjtuOO2YRTIYyTXd17XqJEVhd+rIYosoLi2oB6U7az2HI00j3f+DgB0wbd9zHaI2h2J88a4RhTnAfSCWaWFZyxn19d root@hadoop2.com
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn2yYONHHW25rqBX2X4zUD4qHHXzIf1wtWaLEi1FYOOrB46aWZxVMV/UTA+AowvH4RVV9nw0rldmG6PaEyrNvUZW0t7wripRNxGTldpm2nBg692gSgLy+gQH4i4nG/r/nxXL05XmH+zUJT7sLZYea2S/pH2NZpIkThusR6hiDyfqcTCB22MhRlkdgIh1MgMdFoDlk5jN4ezra6MBWcNg1VBP4xp70+NhSwmt1RutN/puNFkpgUjz5gmOT8ZLZ4R4cwM5H8/ZLljB/8aDkQrneUJ9TIVYAyVZOhD3w7NTpJsfulX6ao71PuFSwje0+V2nctPYP6L1litX4S6t5vDgup root@hadoop3.com
在 hadoop1 中受权authorized_keys
chmod 600 authorized_keys
最初将 authorized_keys
拷贝至 hadoop2, hadoop3 的.ssh 目录下
scp /root/.ssh/authorized_keys hadoop2:/root/.ssh/
scp /root/.ssh/authorized_keys hadoop3:/root/.ssh/
测试 ssh 无明码登录(留神:第一次登录须要明码,之后不再须要)
ssh hadoop2
exit
ssh hadoop3
exit
正文完