Is it possible to alias a username on Linux?

29

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.

Share:
29

Related videos on Youtube

Rehan
Author by

Rehan

Updated on September 18, 2022

Comments

  • Rehan
    Rehan almost 2 years

    I have a public facing site built in ASP.Net. I want Admin/certain users to upload files to particular folder/database table. But currently I don't have any user facility nor any database tables, just some aspx pages hosted on internet.

    Additionally if I use the admin user process, then,
    1. How to differentiate normal users from admin as I am not using any kind of registration process.

    How can I achieve this. Please help.

    • HikeMike
      HikeMike over 12 years
      Are you only interested in a shorter ssh command, or do you want this more generally?
  • Zoredache
    Zoredache over 12 years
    If you do define it with Host * it should be done at the end of the configuration file, so other more specific settings can take precedence.