After I create a new user (newuser) in a EC2 machine (ubuntu), add the authorized_key and try to ssh into it, it doesn't work. Now thats all fine and dandy if it fails, but it actually succeed into login with the old user even if
user@ is set in the command.
How is it possible that the sshd is ignoring the user and falling back for a previous login? No mather what I try, short of removing the key from the other user and restarting the ssh server its not possible to login as the new user.
➜ ~ ssh -l newuser thehost Last login: Thu Nov 2 10:09:08 2017 from 5.x.x.x ubuntu@ip-172-x-x-x:~$ whoami ubuntu ➜ ~ ssh newuser@thehost Last login: Thu Nov 2 10:11:17 2017 from 5.x.x.x ubuntu@ip-172-x-x-x:~$ whoami ubuntu
I speculate that it has something to do with ssh agent or using the keys, but this is terribly confusing to understand and i've never crossed with this before this last two weeks, so I don't know if its a new feature or what.
edit: It seems that it might have something to do with PAM authentication and some caching of the key, since it fully ignores the username. You can type invalid users or anything and it will still login successfully.