It's possible to conditionally set options in the ~/.ssh/config
file.
For example, below shows the usage of a conditional setting of ControlMaster
,
which allows sharing of the SSH network port. But it doesn't work on Windows.
At ~/.ssh/config
:
Match exec "~/.ssh/is-linux.sh"
ControlMaster auto
ControlPath /tmp/ssh-control:%h:%p:%r
At ~/.ssh/is-linux.sh
:
#!/usr/bin/env bash
kernel_name="$(uname --kernel-name)"
[ "${kernel_name#*Linux*}" != "$kernel_name" ] && exit 0 || exit 1
Make sure to run chmod 700 ~/.ssh/is-linux.sh
.