I am trying to connect to my Ubuntu server using ssh and a public key. I have disabled the connection from remote using a password, so I can only login using a key.

There are two users on my server. When I connect using the pubkey for the first user, everything goes fine. Connection is made, key is checked, I get logged in with no issues.

But when I try to log in as the secondary user, then the connection is refused. These were my steps. Suppose my secondary username is tom.

  1. I created a new pair of keys on my system using ssh-keygen -o -a 100 -t ed25519 -f id_tom -C "tom"
  2. copied the public key into the clipboard
  3. once on the server as tom, I made a new .ssh directory within home and created new authorized_keys file, changing the permissions file to 600 and pasted the public key
  4. I appended the following lines to ~/.ssh/config on my local machine:

    Host tom_server
    HostName 687.22.14.4 
    User tom
    IdentityFile ~/.ssh/path/to/id_tom
    IdentitiesOnly yes

Looking at the debug log, I can say that ssh correctly tries to authenticate as tom and the right key is passed to the server. So what could be the issue here? What am I overlooking?

Update: I have tried the solutions posted in Why am I still getting a password prompt with ssh with public key authentication? and nothing so far has worked.

  • did you name the file authorization_keys, or authorized_keys? What are the permissions of ~ and ~/.ssh?
    – Jeff Schaller
    Nov 28 '17 at 14:13
  • 2
  • @JeffSchaller you are right, I made a typo in the question, which I have edited now. I'm not getting the chance to put in a password, because I disabled it. Permissions for ~ are set to 755 and for .ssh are set to 700.
    – haunted85
    Nov 28 '17 at 14:20
  • Just to clarify (you didn't make it explicit), you created .ssh and authorized_keys on the server, not locally, right?
    – Jeff Schaller
    Nov 28 '17 at 14:30
  • 1
    Is the content of auth.log the same for the user that works and the user that doesn't work ? ... there should be a bunch of failures in the auth log for the user that doesn't work... these should all have the suffix [preauth] ... unless sshd logging is turned off for some reason... are you running SELinux on your server? ... You question lacks specific details which are necessary to debug your setup. The precise lines of the log files are informative both in complete content and order. >"received/disconnect/accepted" is not helpful. Nov 28 '17 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.