I created a new user in my EC2 using:

sudo adduser test

I can add it to sudo using "usermod -aG sudo test" and verify it using "groups test", and I can "su - test" to switch to test.

However, when I tried to login this user from another host(my local MAC terminal) using:

ssh test@EC2_IP

it showed permission denied without even asking me password. ssh -v test@EC_IP shows the following log:

OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: key_load_public: No such file or directory
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/XXX/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/XXX/.ssh/id_dsa
debug1: Trying private key: /Users/XXX/.ssh/id_ecdsa
debug1: Trying private key: /Users/XXX/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

In fact, I can login a user of another host. ssh -v another@another_host showed almost the same log except two lines:

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password

for what reason I cannot "ssh test@EC2_IP"? why the system does not check: "debug1: Next authentication method: password"?

  • 1
    Do you have PasswordAuthentication enabled on both the client and server side? – muclux Dec 18 '17 at 8:49
  • If not, share your EC2's /etc/ssh/sshd_config file because it seems to be a misconfiguration in there – XiR_ Dec 18 '17 at 13:12
  • muclux and XiR_. PasswordAuthentication is no in /etc/ssh/sshd_config. I changed it to yes and then "service sshd reload", it now works!. Thanks. note the EC2 to be logged in is new launched, which I did not change anything. looks like amazon's EC2 set PasswordAuthentication as no by default? – user389955 Dec 19 '17 at 15:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.