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

If you have a lot of hosts listed in your ~/.ssh/config file, you can keep the file from getting too cluttered by using the Include directive, which supports wildcards...

    # in ~/.ssh/config
    Include config.d/*.conf

    # in ~/.ssh/config.d/work.conf
    host work
        hostname myoffice.example.com
        user myuser

    # in ~/.ssh/config.d/client1.conf
    host client1.dev
        hostname dev.client.example.net
        user someuser
    
    host client1.prod
        hostname prod.client.example.net
        user someuser



The host directive also supports wildcards.

For example, add `host *_work ` and then some stiff that is the same for all work hosts like host1_work.


There an additional trick - you can put include inside a Host/Match directive.

  # in ~/.ssh/config
  Host proj1.*.corp
    Include ~/.ssh/proj1.conf

  # in ~/.ssh/proj1.conf
  ...
This way, I can put project-specific matches at or near the top, while being sure I don't have to wade through numerous of individual files during review.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: