The sys-apps/shadow package on my GNU / Linux system comes with a
useradd command that supports an option that I have previously overlooked:
--non-unique. For the sake of convenience when shellig home from the university, I have created an alias for my original username (casual name at home) thusly:
useradd --non-unique -u 1001 \
--no-create-home --home-dir /home/casualname \
-g 1001 -G `id casualname -G | tr ' ' ,` universityUsername
This allows me to login from campus with the login universityUsername without creating a ~/.ssh/config alias or specifying the -l option for
ssh. After logging in,
whoami reports that I am casualname. This is due to the fact that casualname appears closer to the top of the /etc/passwd file.
I wonder how widely supported such aliases are and if there are any drawbacks to using them. And also, is there a way to select the preferred user alias as the acting one (what $USER is set to) on a system where the user can not re-order entries in /etc/passwd?