All my boxes have the same username for myself, except one legacy machine where I'm loath to try to change it. Whenever I ssh to the machine, I forget to specify my user name, and my password is rejected. This only takes maybe 30 seconds, but it should only take 3, so it's a PIA.
Is there any way to configure that machine to recognize the incoming username and map it to another, correct, one?
I'd really like to configure this on the server itself if possible. Configuring each client is less ideal, especially since I like to muck with my various installations and VM's quite a bit.
In your
~/.ssh/config
:Then it'll use
otherusername
when you$ ssh otherhostname
.You could add another account on the target server with your desired username, then edit
/etc/passwd
and change the UID to that of the original account. This would give you two usernames for the same account.I'm not sure whether it will introduce any problems as I imagine it violates some spec somewhere, but I've done it temporarily before during server migrations and didn't encounter any issues.
Most programs that map UIDs back to usernames seem to pick the first entry in
/etc/passwd
so reordering the lines should control which username you see in things likels
directory listings (in case you would rather see your new username but have the old one continue to work).You're only likely to run into problems with things that check the username against a string. For example you could do this to create an alias for the
root
account, but then you might encounter a situation wheresudo whoami
returns something other thanroot
which may for example cause an application to abort claiming that you must be the root user to continue, even though you actually were.