概述
在Ubuntu中搭建Hadoop环境时,需要配置SSH免登录,否则启动hadoop会报错:
tancan@ubuntu:~$ start-dfs.sh
Starting namenodes on [ubuntu]
ubuntu: Permission denied (publickey,password).
Starting datanodes
localhost: Permission denied (publickey,password).
Starting secondary namenodes [ubuntu]
ubuntu: Permission denied (publickey,password).
方法
1.生成本机秘钥,执行ssh-keygen -t rsa -P “”命令后,反复按回车即可:
tancan@ubuntu:~/hadoop$ ssh-keygen -t rsa -P ""
Generating public/private rsa key pair.
Enter file in which to save the key (/home/tancan/.ssh/id_rsa):
Your identification has been saved in /home/tancan/.ssh/id_rsa.
Your public key has been saved in /home/tancan/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:YVotNOGxPJnTz4/a6WgdT8TEOl3XqWhCepcME5vnYZo tancan@ubuntu
The key's randomart image is:
+---[RSA 2048]----+
| =o. . o|
| + %o o.+|
| /o*+o=...|
| = B*O+.+ |
| . SE+.oo |
| .o. |
| ..+. |
| .+... |
| .o.+ |
+----[SHA256]-----+
2.将公钥追加到 authorized_keys 文件中
tancan@ubuntu:~$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys
tancan@ubuntu:~$ sudo chmod 600 .ssh/authorized_keys
3.验证是否成功:
tancan@ubuntu:~$ ssh localhost
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.13.0-45-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
118 packages can be updated.
0 updates are security updates.
Last login: Sat Jul 7 05:50:28 2018 from 192.168.0.149
tancan@ubuntu:~$
本文详细介绍了在Ubuntu系统中通过生成本地密钥和将公钥追加到authorized_keys文件来实现SSH免登录,从而解决启动Hadoop时报错的问题。通过执行一系列步骤,可以确保在无需输入密码的情况下顺利启动Hadoop集群。
1371

被折叠的 条评论
为什么被折叠?



