hadoop免密登录却提示输入密码的解决思路
状况描述
在项目系统中上传文件后提示失败
排查解决过程
查看日志发现是hadoop服务没有启动,尝试过程如下
1检查/home/hdfs/下的文件夹及文件权限,确认没有问题
# 700
drwx------ 2 hdfs hdfs 103 Oct 25 11:34 .ssh
# 600 644
-rw------- 1 hdfs es 563 Oct 25 11:34 authorized_keys
-rw------- 1 hdfs es 2590 Oct 25 11:34 id_rsa
-rw-r--r-- 1 hdfs es 563 Oct 25 11:34 id_rsa.pub
2 从命令行直接启动服务,发现还是不行
3 怀疑是免密登录有问题,尝试免密登录,竟然提示输入密码,显示免密登录出现了问题,使用如下命令进行debug
ssh -vvv hdfs
# 最后一段提示如下
debug1: Trying private key: /home/hdfs/.ssh/id_ecdsa
debug3: no such identity: /home/hdfs/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/hdfs/.ssh/id_ecdsa_sk
debug3: no such identity: /home/hdfs/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /home/hdfs/.ssh/id_ed25519
debug3: no such identity: /home/hdfs/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /home/hdfs/.ssh/id_ed25519_sk
debug3: no such identity: /home/hdfs/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /home/hdfs/.ssh/id_xmss
debug3: no such identity: /home/hdfs/.ssh/id_xmss: No such file or directory
debug1: Trying private key: /home/hdfs/.ssh/id_dsa
debug3: no such identity: /home/hdfs/.ssh/id_dsa: No such file or directory
debug2: we did not send a packet, disable method
4 尝试使用如下命令,行不通,放弃
ssh-keygen -t id_ecdsa -P '' -f ~/.ssh/id_ecdsa
# 提示
unknown key type id_ecdsa
5 在另外一台虚拟机,切换到hdfs账号,重新配置免密登录,免密登录成功,说明配置方式是没有问题
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys
6 在问题服务器上,切换到root账号,直接删除原来的用户,重新创建hdfs账号,然后配置免密登录,免密登录成功
# 删除原有账号
userdel -r hdfs
# 切换hdfs账号,配置免密登录
su hdfs
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys
7 如有遇到权限问题,根据提示调整文件权限即可
参考资产
- Apache Hadoop 2.10.2 – Hadoop: Setting up a Single Node Cluster.
- linux用户管理----创建用户(adduser和useradd)和删除用户(userdel)_录事参军的博客-CSDN博客_linux创建用户
- Linux下用户组、文件权限详解 - 打伞的鱼 - 博客园 (cnblogs.com)
- systemctl 针对 service 类型的配置文件 | 鸟哥的 Linux 私房菜:基础学习篇 第四版 (gitbooks.io)
- Linux systemd 系統服務管理基礎教學與範例 - G. T. Wang (gtwang.org)
- 3 ways to fix Host key verification failed in ssh - howtouselinux