Imagine you have X sites and each site has a naming schema they use for proxy access. I’d like to create an ssh config file that would satisfy all X sites but not duplicate my ssh config.
For example, if I’m at an ssh host at site A I want the ssh config file to derive that it’s on a site A host by taking the first 3 characters of the host name. this is a dummy config file, but only site A hosts can access site A hosts. only site B for site B… etc. instead of having 4 entries I’d like to just use 2.
<code>Host siteA*-worker
ProxyCommand ssh -qxT -At siteA_security nc %h %p
Host siteA*-worker2
ProxyCommand ssh -qxT -At siteA_security nc %h %p
</code>
<code>Host siteA*-worker
ProxyCommand ssh -qxT -At siteA_security nc %h %p
Host siteA*-worker2
ProxyCommand ssh -qxT -At siteA_security nc %h %p
</code>
Host siteA*-worker
ProxyCommand ssh -qxT -At siteA_security nc %h %p
Host siteA*-worker2
ProxyCommand ssh -qxT -At siteA_security nc %h %p
should be something like
<code>Host $(hostname | cut -c1-2)*-worker
ProxyCommand ssh -qxT -At $(hostname | cut -c1-2)_security nc %h %p
Host $(hostname | cut -c1-2)*-worker2
ProxyCommand ssh -qxT -At $(hostname | cut -c1-2)_security nc %h %p
</code>
<code>Host $(hostname | cut -c1-2)*-worker
ProxyCommand ssh -qxT -At $(hostname | cut -c1-2)_security nc %h %p
Host $(hostname | cut -c1-2)*-worker2
ProxyCommand ssh -qxT -At $(hostname | cut -c1-2)_security nc %h %p
</code>
Host $(hostname | cut -c1-2)*-worker
ProxyCommand ssh -qxT -At $(hostname | cut -c1-2)_security nc %h %p
Host $(hostname | cut -c1-2)*-worker2
ProxyCommand ssh -qxT -At $(hostname | cut -c1-2)_security nc %h %p