Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 '14 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 '14 at 12:56
@tohecz Looking at man ssh_config and searching for User gives the result in about 30 sec. So, as slm says, it is very basic. I'm not suggesting asking such a question is a bad thing - one does have to know where to look, and that may not be obvious. I ask basic questions sometimes too, but some people may not like it. I'm also not justifying the downvote. I don't believe in them, except for spam. – Faheem Mitha Apr 24 '14 at 14:49
@FaheemMitha That sounds like I should know where to look. I consider any further discussion in this manner pointless. – yo' Apr 24 '14 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 '14 at 15:09
up vote 29 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 man ssh_config 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 '14 at 17:48
why only link to a web site for documentation that would be installed on almost every system with the openssh client installed? links die. local man pages are forever. at least mention that the info is available by running man ssh_config. – cas Nov 10 '15 at 9:43

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.