If you want to start a ssh client, you could do this in bash:
#files are .ssh/config and ~/.ssh/foo.config
alias ssh='ssh -F <(cat .ssh/config ~/.ssh/foo.config)'
then you use ssh normally and it will have both files read in that order.
For the server daemon sshd
you could do the same, just use -f
instead of -F
and write this down where you start the daemon directly. you don't need an alias.
A second possibility according to the man page is to put the system wide configuration in /etc/ssh/ssh_config
and the user one in ~/.ssh/config
.
Update Apparently there is a problem with some bash versions and how the devices are created. (see http://bugs.alpinelinux.org/issues/1465)
This is a workaround (though in my opinion ugly):
mkfifo /tmp/ssh_fifo
cat ~/.ssh/config ~/.ssh/foo.config >/tmp/ssh_fifo &
ssh -F /tmp/ssh_fifo myserver
rm /tmp/ssh_fifo
so if you want, you may create a function out of it (or a script):
ssh() {
tmp_fifo=$(mktemp -u --suffix=_ssh_fifo)
mkfifo "$tmp_fifo"
cat ~/.ssh/config ~/.ssh/foo.config >"$tmp_fifo" 2>/dev/null &
/usr/bin/ssh -F "$tmp_fifo" "$@"
rm "$tmp_fifo"
}