Can one use the output of a command/script in an ssh_config 'match'?

Brian Candler b.candler at pobox.com
Sun Nov 8 23:42:36 AEDT 2026


On 08/11/2026 12:15, Chris Green wrote:
> I have a script which generates a list of hosts, it's used in various
> places on my LAN systems for configuration management and such.
>
> It would be very handy if I could use its output in a match in my
> ~/.ssh/config file.  I.e. I would like to be able to do something like:-
>
>      Match host $(listofhosts) exec <bla bla bla>
>         <set something>
>         <set something else>
>
> where '$(listofhosts)' inserts the output of listofhosts in the Match line.
>
> Is there any way of doing something like this?  I've looked through the
> ssh_config man page quite carefully and I don't see anything, but
> (hopefully) maybe I'm missing something.

Use a second "exec" block to match on the hostname.



More information about the openssh-unix-dev mailing list