Ubuntu: SSH still asks for the publickey even if I try to connect with a user I created with a password



Question:

I created an instance on DreamCompute (DreamHost) 4 months ago. To connect to it via ssh you need to create a key pair and access with the public key with the user dhc-user: I remember that when I logged the first time I created a new user with a password, so that I could connect to the server without the public key and it worked flawlessly.

Now that I terminated that instance and created a new one, I did the same thing but when I try to connect to the user I added it gives me the error Permission denied (publickey).

$ ssh -v user@IPADDRESS  OpenSSH_6.9p1, LibreSSL 2.1.8  debug1: Reading configuration data /etc/ssh/ssh_config  debug1: /etc/ssh/ssh_config line 21: Applying options for *  debug1: /etc/ssh/ssh_config line 56: Applying options for *  debug1: Connecting to IPADDRESS [IPADDRESS] port 22.  debug1: Connection established.  debug1: key_load_public: No such file or directory  debug1: identity file /Users/user/.ssh/id_rsa type -1  debug1: key_load_public: No such file or directory  debug1: identity file /Users/user/.ssh/id_rsa-cert type -1  debug1: key_load_public: No such file or directory  debug1: identity file /Users/user/.ssh/id_dsa type -1  debug1: key_load_public: No such file or directory  debug1: identity file /Users/user/.ssh/id_dsa-cert type -1  debug1: key_load_public: No such file or directory  debug1: identity file /Users/user/.ssh/id_ecdsa type -1  debug1: key_load_public: No such file or directory  debug1: identity file /Users/user/.ssh/id_ecdsa-cert type -1  debug1: key_load_public: No such file or directory  debug1: identity file /Users/user/.ssh/id_ed25519 type -1  debug1: key_load_public: No such file or directory  debug1: identity file /Users/user/.ssh/id_ed25519-cert type -1  debug1: Enabling compatibility mode for protocol 2.0  debug1: Local version string SSH-2.0-OpenSSH_6.9  debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.4  debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.4 pat OpenSSH_6.6.1* compat 0x04000000  debug1: Authenticating to IPADDRESS as 'user'  debug1: SSH2_MSG_KEXINIT sent  debug1: SSH2_MSG_KEXINIT received  debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none  debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none  debug1: expecting SSH2_MSG_KEX_ECDH_REPLY  debug1: Server host key: ecdsa-sha2-nistp256 SHA256:blablablabla  debug1: Host 'IPADDRESS' is known and matches the ECDSA host key.  debug1: Found key in /Users/user/.ssh/known_hosts:1  debug1: SSH2_MSG_NEWKEYS sent  debug1: expecting SSH2_MSG_NEWKEYS  debug1: SSH2_MSG_NEWKEYS received  debug1: SSH2_MSG_SERVICE_REQUEST sent  debug1: SSH2_MSG_SERVICE_ACCEPT received  debug1: Authentications that can continue: publickey  debug1: Next authentication method: publickey  debug1: Offering RSA public key:   debug1: Authentications that can continue: publickey  debug1: Trying private key: /Users/user/.ssh/id_rsa  debug1: Trying private key: /Users/user/.ssh/id_dsa  debug1: Trying private key: /Users/user/.ssh/id_ecdsa  debug1: Trying private key: /Users/user/.ssh/id_ed25519  debug1: No more authentication methods to try.  Permission denied (publickey).  


Solution:1

You're using the wrong SSH key, or it's not valid for the server you're trying to connect to.

Check that the key you're using is in fact valid for the server. If you saved it somewhere else, use ssh -i <path_to_key> to force that specific key.

If you don't actually have a key, you need to use the DreamCompute console to either add one temporarily, or disable it from the recovery console (if it has one).

Note: Disabling the SSH key authentication to fallback to a password is a bad idea! SSH keys are much more secure than a password ever could be, and it's highly recommended you keep it enabled.


Then, to disable SSH key authentication on the server, you have to actually, well, turn it off.

In /etc/ssh/sshd_config, there are the following lines:

# Change to no to disable tunnelled clear text passwords  PasswordAuthentication no  

Change that no to yes using your favorite text editor, and then restart the ssh service by running: sudo service ssh restart.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »