This question is not a duplicate. Please read it before you mark it as such.
Is it possible to assign nicknames or aliases to users on a Linux sever and SSH into the server using the nicknames? I am thinking something along the lines of the aliases for various commands that get added to the .bashrc
or the .bash_aliases
file, e.g.:
alias grep='grep --color=auto'
For example, if there is a requirement (business rule) to set up users on the server with their full name, e.g., john_smith
instead of just their first name (john
) but we want to nickname john_smith
fruitloops
and we want John to be able to:
ssh john_smith@ip_address
as well as:
ssh fruitloops@ip_address
If it is possible, where would the mapping between a user and their nickname be set up? Would the user fruitloops
also need to exists on the sever?
This question is about setting up an alias for a user, not a host.
Each user in linux has only one name and that is his only name. you can create aliases for commands not for users.
But you can create a second user with the same UID, home directory and password that would do the trick for you.
I haven't tried this but another option besides the two users mapped to a single UID (which IMO seems dangerous but this option is probably equally dangerous) is to have a single user serve as a redirector based on SSH key. This is how source control repositories that use SSH typically work.
Lets call the user
me
. Everyone will use this alias.Now the user
me
has all of users public keys in their~/.ssh/authorized_keys
.You will need to make the user
me
have the ability to sudo as the other users and you will need to manageme
authorized keys file.Anyway I haven't tested this but in theory something like this should work.