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
1  
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
1  
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
1  
@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
2  
@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
1  
@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

1 Answer 1

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

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.