ssh root@server 'Permission denied (publickey)'

September 21, 2017 368 views
Security Ubuntu 16.04

SSH authentication works and happens automatically when I log into my server with Putty. However, when I run ssh root@server or ssh new_user@server, after following the tutorial on adding a new user and giving it root permissions, I get 'permission denied (publickey)'. Should I worry about this, are either of my users secure?

2 Answers

i have the same question how to reslove it

  • After a long time away from my droplet, I had this same problem.

    I simply had to remember that I use "ssh -i <key-file> user@server"
    Where the key file is the the one you generated during the tutorial.

Assuming you created the .ssh folder and public key file within your new user, make sure you are referencing the proper private key when you ssh login.

  • How would i reference a particular key?

    • Generally, when you setup your key pair (public and private keys) they are placed in the ~/.ssh directory.

      To reference a particular key, use the -i (identity) command line option.

      For example:
      ssh -i .ssh/my-user-key my-user@my-host-ip

      Where my-user-key is the file name for the private key you generated for your user on your local machine.

      my-user is the username on your droplet

      my-host-ip is the ip address of the host you're ssh'ing to.

      Search for "how to log in with ssh" in this forum.

Have another answer? Share your knowledge.