How to specify multiple HostName/Port combinations in .ssh/config

I'm afraid that is not possible with SSH.

You could possibly work around this using the ProxyCommand option of ssh, along with a custom script that creates a TCP connection to a server (using netcat), depending on how/where your notebook is connected. Something along the lines of:

#!/bin/bash
SSID=$(/sbin/iwgetid wlan0 -r)

case "$SSID" in
net1)
  nc <host1> <port1>
  ;;
net2)
  nc <host2> <port2>
  ;;
*)
  nc <host3> <port3>
  ;;
esac

Then, in your .ssh/config, you would need the following:

Host repo-server
  User user143
  IdentityOnly yes
  IdentityFile ~/hgkey
  ProxyCommand path-to-script

Tags:

Ssh