Is it possible to alias a username on Linux?

I'm not sure if this has a practical application at all (aside from the fact that I am lazy. you know "christopher" has 11 characters, and I want to type 1), but is it possible to alias a username on Linux? (So I could, for example, ssh [email protected] as opposed to ssh [email protected].)

I currently use Ubuntu as my primary machine, but if it is possible in any of the distro's, I'd like to know.


Solution 1:

Create a file named ~/.ssh/config and put this in there:

Host h
User christopher
HostName my.domain.top

Now you only have to type ssh h and it does the same thing!

You can also use a wildcard:

Host *
User christopher

Solution 2:

You could create a second user, c, with the same UID. From here:

The UID is the actual information that the operating system uses to identify the user; usernames are provided merely as a convenience for humans. If two users are assigned the same UID , UNIX views them as the same user, even if they have different usernames and passwords. Two users with the same UID can freely read and delete each other's files and can kill each other's programs. Giving two users the same UID is almost always a bad idea; we'll discuss a few exceptions in the next section.

Chapter 4.1.2 explains when it might be useful. This is not one of the suggested use cases though!

Solution 3:

For the ssh specific case: if your username is the same on both machines you can omit the username completely.