SSH-permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

 ( 1 ) 创建用户: hadoop

(2)配置ssh服务器配置文件。

在root 用户下才能配置。

vi /etc/ssh/sshd_config  权限设为no:

#PermitRootLogin yes

#UsePAM yes

#PasswordAuthentication yes

如果前面有# 号,将#号去掉,之后将yes修改为no。修改之后为:

PermitRootLogin no

UsePAM no

PasswordAuthentication no

权限设为yes:

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile      .ssh/authorized_keys

# /etc/init.d/sshd restart  // 然后重启服务

(3)cd /home/hadoop 

ssh-keygen -t rsa 一直回车

然后一直按回车,选择默认的操作即可。

$ ssh localhost
  • 成功
$ ssh node1
  • 失败:报错:permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

解决

原来我没有做一个很重要的操作! 
那就是将生成的密钥文件,拷贝到authorized_keys中

可以使用

$cp id_rsa.pub  authorized_keys
  • 也可以使用输出流重导向的方法
cat id_rsa.pub >>authorized_keys

猜你喜欢

转载自blog.csdn.net/lxlmycsdnfree/article/details/81608275