When connecting to a new cloud server, I repeatedly received Password authentication failed. Resetting the password and editing sshd_config did not solve it.
The original command omitted the remote username:
1 | ssh PUBLIC_IP |
That makes SSH use the current local username, which may not exist on the server. Supplying the expected remote account fixed the connection:
1 | ssh -v root@PUBLIC_IP |
-v prints diagnostic information, while root@ selects the remote account. Many cloud images disable direct root login; in that case use the image’s documented default user, such as ubuntu, ec2-user, or a custom account:
1 | ssh -vvv -i ~/.ssh/server_key ubuntu@PUBLIC_IP |
Also verify the security-group/firewall rule for port 22, key-file permissions, server username, and server authentication logs. Prefer key authentication and a non-root administrative account over enabling root password login.