1

I have a ubuntu 16.04 server install that was initially installed with root user only so root users home directory is /root. If I add another user such as bob bobs home directory is created in /home/ as expected. If I want add a public key for bob to ssh in with, I add /home/bob/.ssh/authorized_keys and put bobs public key in the authorized key file. Is this the correct way so far? Problem is when I try

ssh bob@server.com 

I get

Permission denied (publickey)

The .ssh directory permissions are set to 700 and the authorized_key file is set to 600. In my sshd_config the path to the key file is the default

#AuthorizedKeysFile     %h/.ssh/authorized_keys

I set ssh logging to verbose but it only shows

Failed publickey for....

What could I be doing wrong? Is it only looking in /root/.ssh for the key file?

antzshrek
  • 350
sealfab
  • 173

2 Answers2

0

If you are using ssh bob@server.com then based on your sshd_config file, the server is looking in the correct location (i.e. /home/bob/.ssh/authorized_keys).

However, based on your description I cannot tell if the key that you pasted in to the authorized_keys file is in fact the same one that the client is trying to ssh with. Rather than manually pasting it into the authorized_keys file, using ssh-copy-id bob@server.com from the client machine will ensure that the public key in use by the ssh client is correctly added to your server's authorized_keys file (for user bob).

Jeff
  • 920
0

Verifying that you're using the correct key is the first step. Also check the sshd config to make sure public key authentication is enabled:

RSAAuthentication yes
PubkeyAuthentication yes

Then also check to see if there are any "allow/deny" settings like "AllowGroups", "DenyGroups", "AllowUsers", and "DenyUsers" which will prevent anyone not in that group or user from logging in. Another setting is "AuthenticationMethods" which may prevent the public key authentication alone from working.

CR.
  • 1,199