Question

How can I ssh access on my second computer (ubuntu)? Permission denied (publickey)

Posted July 9, 2020 139 views
DigitalOceanUbuntu 20.04

I have a ssh access via terminal on my mac working fine. Lately I got another computer (Ubuntu 20 Linux). I am trying to set up ssh access, but it just does not let me in, saying “Permission denied (publickey)”.

I added my ssh pub key (id_rsa.pub) on my local computer(Ubuntu) to the Digital Ocean (settings -> security). But, it does not fix the issue.

I also pasted the pub key in ~/.ssh/authorized_keys in the droplet.

What do I need to do to ssh access on my local ubuntu machine?

FYI: I can set password login by changing PasswordAuthentication yes in /etc/ssh/sshd_config in the droplet. However, this is not ssh access without password.

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.

×
1 answer

Hi there @nfujioka,

You would need to first create a new SSH key pair on your Ubuntu computer. You can follow the steps on how to do that here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys–2

Once you have your keys ready, copy your public key and add it to your Droplet in the ~/.ssh/authorized_keys.

That way you will be able to SSH with your new key pair from your Ubuntu computer to your Droplet.

Hope that this helps!
Regards,
Bobby

by Etel Sverdlov
SSH keys provide a more secure way of logging into a virtual private server with SSH than using a password alone. With SSH keys, users can log into a server without a password. This tutorial explains how to generate, use, and upload an SSH Key Pair.
  • Hi, I have already done that with my existing ssh keys. But, it does not work. Do you mean I cannot use my existing key? I use it with github and works fine with github but not with digital ocean droplet.

    • Hi there @nfujioka,

      In order to be able to use your existing key, you need to add your private key to your Ubuntu server. So basically copy the ~/.ssh/id_rsa file from your Mac to your Ubuntu Laptop.

      And one more thing to add here is that your ~/.ssh needs to be set to 700 permissions:

      • chmod 700 ~/.ssh

      And your private key needs to have 600 permissions for security reasons, otherwise, it would not work:

      • chmod 600 ~/.ssh/id_rsa

      If this still does not work, you could run the ssh command with the -vvv argument to see some verbose information and the possible root cause of the problem:

      ssh -vvv root@your_ip_address
      

      Hope that this helps!
      Regards,
      Bobby

Submit an Answer