Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 c@my.domain.top as opposed to ssh christopher@my.domain.top.)

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

share|improve this question
3  
Are you only interested in a shorter ssh command, or do you want this more generally? –  Daniel Beck Dec 13 '11 at 18:28
add comment

3 Answers 3

up vote 18 down vote accepted

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
share|improve this answer
5  
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. –  Zoredache Dec 13 '11 at 23:02
add comment

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!

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.