Question

Publickey access denied user but Root okay

Posted June 8, 2018 1.8k views
UbuntuDigitalOcean

When i tried ssh using root access

debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:PSQnv/ajononHTf15aPXn8WHG5OjLIK6DozzlmQrtw4 /Users/enz/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp SHA256:PSQnv/ajononHTf15aPXn8WHG5OjLIK6DozzlmQrtw4
debug3: sign_and_send_pubkey: RSA SHA256:PSQnv/ajononHTf15aPXn8WHG5OjLIK6DozzlmQrtw4
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).

it can continue, but when i tried ssh using the user that i create

debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:PSQnv/ajononHTf15aPXn8WHG5OjLIK6DozzlmQrtw4 /Users/enz/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/enz/.ssh/id_dsa
debug3: no such identity: /Users/enz/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /Users/enz/.ssh/id_ecdsa
debug3: no such identity: /Users/enz/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /Users/enz/.ssh/id_ed25519
debug3: no such identity: /Users/enz/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
c_rs@lupa.cukopi.com: Permission denied (publickey).

i’m already create .ssh folder and authorize_keys

anyone can help me with it?

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
4 answers

Hello,

You need to add your SSH key to your user’s /home/user/.ssh/authroized_keys file in order to be able to ssh.

Also, you need to make sure that the /home/user/.ssh and the authorized_keys file has secure permissions.

Regards,
Bobby

Hello there,

As per Bobby’s comment, you need to add your public key to the authorized_keys file.

You can check our article on How to Upload an SSH Public Key to an Existing Droplet

https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-existing-droplet/

You can access the droplet from the DigitalOcean console and then temporary enable the PasswordAuthentication on your droplet and access the droplet with a password to upload the ssh-key.

If you haven’t created new pair of keys you’ll need to do that first.

You can enable PasswordAuthentication for your Droplet by modifying your /etc/ssh/sshd_config file. Once set to Yes restart the SSH service and connect via an SSH client for a more stable connection. You can then modify your ~/.ssh/authorized_keys file to add the appropriate public key.

This change can be made from DigitalOcean’s console. If you’re having issues accessing the console you can then reach to our amazing support team that can help you further with this.

To enable the PasswordAuthentication follow these steps:

  1. Login to the console on the DigitalOcean website.
  2. Type sudo nano /etc/ssh/sshd_config
  3. Change PasswordAuthentication from “no” to “yes” and save the file
  4. Open a terminal on your computer and type ssh username@[hostname or IP address] or if on a Windows box use PuTTY for password login making sure authentication parameters aren’t pointing to a private key
  5. Login with a password
  6. Type sudo nano ~/.ssh/authorized_keys
  7. Paste public key text here and save the file
  8. Type sudo nano /etc/ssh/sshd_config
  9. Change PasswordAuthentication from “yes” to “no” and save the file
  10. Log out and attempt to log back in (if using PuTTY make sure you set up auth parameters to point to your private key)

You can then upload the key using this command:

ssh-copy-id -i ~/.ssh/mykey user@droplet

Hope that this helps!
Regards,
Alex

This question was answered by @MSNK:

I am facing this issue..... can anyone please help?

View the original comment