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.
- I created a new pair of keys on my system using
ssh-keygen -o -a 100 -t ed25519 -f id_tom -C "tom" - copied the public key into the clipboard
- once on the server as
tom, I made a new.sshdirectory withinhomeand created newauthorized_keysfile, changing the permissions file to600and pasted the public key I appended the following lines to
~/.ssh/configon 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.
authorization_keys, orauthorized_keys? What are the permissions of~and~/.ssh? – Jeff Schaller Nov 28 '17 at 14:13~are set to755and for.sshare set to700. – haunted85 Nov 28 '17 at 14:20authorized_keys2file by any chance? I admit I don't know why, but I;ve seen some systems useauthorized_keys2instead ofauthorized_keys. – terdon Nov 28 '17 at 14:32authorized_keys. – haunted85 Nov 28 '17 at 14:41debug1: Offering public key tom... followed bydebug2: we sent a publickey packet– RubberStamp Nov 28 '17 at 14:48sshdfinds the matching key inauthorized_keysand logs me in. And yes if I launchssh -vvv tom_serverI getdebug 1: Offering public key...and laterdebug 2: we sent a publickey packet...– haunted85 Nov 28 '17 at 15:00cat /var/log/auth.log |grep "sshd.*your.host.ip.addr"– RubberStamp Nov 28 '17 at 15:50auth.logthe 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. – RubberStamp Nov 28 '17 at 16:45