Glam Prestige Journal

Bright entertainment trends with youth appeal.

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 

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?

2 Answers

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 user test and your ssh server also have user test then no need to mention username like :

ssh 

you can use like:

ssh myserver.com
ssh serverip

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 :

su - user1
ssh sshserverip

you will login as user1. if you do

su - user2
ssh sshserverip

you 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.

ssh username@serverip 

or

ssh serverip -l username 

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 Documentation

2

If you don't mention the username, ssh will use the username you are currently logged in as.

So:

username@client$ ssh 

is analogous to:

username@client$ ssh myserver.com

All the other parameters like keys, passwords will be used in the usual manner.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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