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.

link|improve this question

feedback

1 Answer

up vote 5 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

link|improve this answer
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
feedback

Your Answer

 
or
required, but never shown

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