Today I configured ssh keys access to my server. Then I tested them and by mistake I forgot to specify the user, so instead of doing it like that:
ssh [email protected]
I did it like that
ssh myserver.combut
I successfully logged in as username. How is that possible? How does ssh server know under which user to log me in? If it's a key, than it's possible that I'll have the same key added to multiple users, what's going to happen in this case?
If same user you have in your system from which you want to login then no need to use
username
for login it will take default system user. for example : your one system(client) have usertest
and your ssh server also have usertest
then no need to mention username like :you can use like:
make sure when you doing ssh you have login as that user in your client system. yes, you can do for multiple users like your client system have user
user1
,user2
,user3
etc. then you have to create that user in your ssh server also . then if you want to login then do like :you will login as
user1
. if you doyou will login as
user2
. If you want login as another user then you have to put username otherwise system will confuse which user have to login.or
or
if you want to do key based authentication then you have to add public key of all users in
authorized_keys
. for more info visit Ubuntu DocumentationIf you don't mention the username,
ssh
will use the username you are currently logged in as.So:
is analogous to:
All the other parameters like keys, passwords will be used in the usual manner.