Hacker News new | past | comments | ask | show | jobs | submit login

The ~/.ssh/config file was something I discovered when my my company was going through some changes and I had 2 different usernames for accessing internal systems.

   Host hosta hostb hostc
   User usera
   
   Host *
   User userb
Since my local system username was different than many of the remote systems I could wildcard to a different default username then had a list of servers that would use my other username.

The bad thing is, as the blog post shows, "Host" above is really just an alias. So if I have an entry like:

   Host hosta.mycompany.com
   User usera
and then try to do "ssh hosta", even if hosta resolves to hosta.mycompany.com, it won't match the config entry, as config entry data is all used prior to DNS lookup.

EDIT: thanks for all the suggestions below.




You can do:

    Host hosta hostb hostc
    HostName %h.mycompany.com
    User usera
I believe this isn't a super-new feature -- every ssh version I've run into client-side in the last couple years has supported it.


You should be able to do something like:

  Host hosta* hostb* hostc*
  User usera
Assuming you don't have two different machines named hosta with different domain names, it should do what you want.


so, I would say that the easiest solution here is tab completion. Suitably modern bash-completion should expand entries in ~/.ssh/config (as well as ~/.ssh/known_hosts if its not hashed).

  Host hosta.mycompany.com
    User usera
and then type "ssh hosta<tab>" :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: