ubuntu配置SSH免密码登陆,提示Permission denied (publickey).

前端之家收集整理的这篇文章主要介绍了ubuntu配置SSH免密码登陆,提示Permission denied (publickey).前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在使用EC2的ubuntu实例创建Hadoop集群时,配置ssh密钥出现问题:

ubuntu@ip-172-31-30-202:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ubuntu/.ssh/id_rsa.
Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub.The key fingerprint is:c:9e:43:1:5c:97

ubuntu@ip-172-31-30-202

The key's randomart image is:
+--[ RSA 2048]----+
| . |
| .E |
| .. . |
| . . |
| . |
| .. |
| = |
+-----------------+

ubuntu@ip-172-31-30-202:~$ cd .ssh
ubuntu@ip-172-31-30-202:~/.ssh$ ls
authorized_keys id_rsa id_rsa.pub
ubuntu@ip-172-31-30-202:~/.ssh$ ssh-copy-id ubuntu@ip-172-31-29-124
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s),to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Warning: Permanently added 'ip-172-31-29-124,172.31.29.124' (ECDSA) to the list of known hosts.
Permission denied (publickey).

在向其他节点复制公钥时总是提示:Permission denied (publickey).

找了很多种解决方案如下:

http://blog.chinaunix.net/uid-22556372-id-1773417.html

http://blog.itpub.net/25851087/viewspace-1262468/

但是都没解决我的问题,后来找到了原因,因为我的新的实例并没有在当前用户上创建登录密码,导致在识别用户时无密码作为权限标识,所以提示无权限,解决办法如下:

ubuntu@ip-172-31-31-26:~$ sudo passwd ubuntu
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

ubuntu@ip-172-31-31-26:~/.ssh$ ssh-copy-id ubuntu@ip-172-31-31-25
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s),to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
ubuntu@ip-172-31-31-25's password:


Number of key(s) added: 1


Now try logging into the machine,with: "ssh 'ubuntu@ip-172-31-31-25'"
and check to make sure that only the key(s) you wanted were added.


ubuntu@ip-172-31-31-26:~/.ssh$ ssh ubuntu@ip-172-31-31-25

即可解决这个问题,可能在种情况的原因有很多种,我的解决方式仅供参考。

原文链接:https://www.f2er.com/ubuntu/355929.html

猜你在找的Ubuntu相关文章