I wanted to use ssh authentication agent forwarding on a few hosts at work because I only keep my private keys at work on my workstation. You enable this on a case by case agent with the ‘-A’ option, but I don’t like remember such things, so you can add ‘ForwardAgent yes’ to your ~/.ssh/config file. However, it seemed unneeded to enable this for all hosts, as it’s got a slight security issue or two. You can limit the commands to a certain host by preceding the command with a ‘Host server_hostname’ line, but ‘server_hostname’ must match whatever you write on the command line. You can use wildcards to match a domain like ‘*.example.org’ but I really only use hostnames not fqdns when I use ssh, so I wanted to list multiple hostnames. You can do this like so:
Host *
ForwardX11 yes
ForwardX11Trusted no
Host ops ops.example.org secretbox otherbox
ForwardAgent yes
Nice tip, I was looking for exactly this today, thanks! One point to note, when configuring contrasting options for different hosts, the specific Hosts directive must come before the “generic” one…
Hosts ops.example.org
Compression no
Hosts *
Compression yes