2
votes

I would like to use a ssh_config file instead of the traditional ~/.ssh/config. I have a simple configuration for accessing hosts through a bastion host (on port 23 for example).

ssh_config :

host bastion
    hostname bastion.mydomain.com
    port 23

host *.server
    proxycommand ssh -W %h:%p bastion

ssh -F ssh_config test.server is not working and throw me "ssh: Could not resolve hostname bastion: Name or service not known".

But, if put this config in ~/.ssh/config, then ssh test.server works.

As I understand it, the proxycommand is unable to use the config file given in the command line. If I want my command line config file to work, I need to put

    proxycommand ssh -W %h:%p bastion.mydomain.com -p 23

but this seems to violate a simple DRY principle (the port and the domain are repeated). The config file I'm willing to build is much much longer and complex.

Is there a good way to achieve what I want, i.e. a simple, non-repeating, config file usable in command line for which proxycommand works ?

2
specifying proxycommand -F ssh_config does work. But then I need to repeat this everywhere in the config_file. And changing the name of the file is catastrophic. So my question about a better way to achieve that should still stand. - ElBidoule
Could you explain to us why you're trying to avoid using the normal ~/.ssh/config file? That is obviously the easiest solution. Otherwise, specifying -F path/to/config anywhere you invoke ssh is probably your best bet. - larsks
@larsks I would like to put this config file in a git repo and have an ansible configuration that get along with. Thanks for the quick, but depressing, answer. - ElBidoule

2 Answers

1
votes

Half of an answer: Rather than using the config file recursively, try not relying on the config at all for the proxy command.

host *.server proxycommand ssh -W %h:%p bastion.mydomain.com -p 23

This allows it to be portable, but doesn't solve your other issue of having to do this on every line, and makes changing the bastion host address a difficult process.

0
votes

you need to pass proxycommand ssh -W %h:%p bastion -F [your custom ssh config]