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. –  tohecz Apr 24 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 at 12:56
    
@slm I've tried searching ssh username which did not give any reasonable response :-/ –  tohecz Apr 24 at 13:01
    
Understand, but that is likely the reasons for the DV. –  slm Apr 24 at 13:02
1  
@FaheemMitha That sounds like I should know where to look. I consider any further discussion in this manner pointless. –  tohecz Apr 24 at 15:03
show 2 more comments

1 Answer 1

up vote 15 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
3  
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
add comment

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.