Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a different (assigned, non-changable) username on one of the servers I log to regularly, and I would like to avoid writing it down every time. Can I make these lines

[tohecz@localhost ~]$ ssh myserver.cz
[tohecz@localhost ~]$ ssh anotherserver.cz

behave as the following?

[tohecz@localhost ~]$ ssh tohecz@myserver.cz
[tohecz@localhost ~]$ ssh anotheruser@anotherserver.cz
share|improve this question
Can I ask why the question got downvoted? Have I done anything wrong? If so, please exaplain it to me so that I can improve the post. –  yo' Apr 24 at 12:22
I did not DV this but typically Q's that are very basic such as this or show little effort in searching prior to asking are viewed negatively. Also searching this site would've yielded many A's that show the below A: unix.stackexchange.com/search?q=ssh+user+host –  slm Apr 24 at 12:56
@slm I've tried searching ssh username which did not give any reasonable response :-/ –  yo' Apr 24 at 13:01
@FaheemMitha That sounds like I should know where to look. I consider any further discussion in this manner pointless. –  yo' Apr 24 at 15:03
@tohecz At the risk of redundancy, no disrespect or offense to you is intended. This was by way of response to you asking about the downvote. –  Faheem Mitha Apr 24 at 15:09

1 Answer 1

up vote 16 down vote accepted

Add the following in your ~/.ssh/config file:

Host myserver.cz
  User tohecz

Host anotherserver.cz
  User anotheruser

You can specify a lot of default parameters for your hosts using this file. Just have a look at the manual for other possibilities.

share|improve this answer
Regarding other default parameters, I like shortening the host, along the lines of Host web / Hostname www.mysite.com / User foo –  Kevin Apr 24 at 17:48

Your Answer


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.