Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I ssh between different pcs I can omit my username (tom) and just type

ssh pc_name

instead of

ssh tom@pc_name

I like this feature, and have got into the habit of using it.

Unfortunately, on one of my computers I went for the user name tommy. Everytime I connect to this computer I forget to write tommy@creative_pc and wonder why my password doesn't work. Is there a way to tell ssh what user name to use when the username is omitted?

Edit: Just found the following question that is similar: How to make ssh log in as the right user? It didn't come up on my initial search.

share|improve this question

2 Answers

up vote 11 down vote accepted

Sure:

$ ssh -l tommy

will log you in as tommy.

You can also make this persistent per-host by having a record like this in ~/.ssh/config:

Host creative_pc
User tommy
HostName creative_pc # put the full host name here or the IP if it is static

then you just do:

$ ssh creative_pc # this is the string from Host setting

and you login there as tommy by default

share|improve this answer
1  
Perfect response. @Tom - if you want more info, this is discussed in the ssh man page: linuxmafia.com/pub/os2/stahl-ssh/snafu-mirror/ssh.html – Doc Jul 4 '11 at 15:16
Ace, I knew there must be a way. thanks! – Tom Jul 4 '11 at 15:20
For those of you wanting a default login-user for ALL remote servers. Use '*' as Host wildcard (Host *). – Jan1337z 2 days ago

I have a large list of servers, so I used a shell alias to set a default user for all hosts. Put bellow line on your ~/.bashrc:

alias ssh="ssh -l default_user"

You can still set another user, using -l:

ssh server -l other_user

I started using today, seems working fine on Ubuntu 12.

share|improve this answer

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.