Bug 2462

Summary: Option to try connectiing to multiple DNS names
Product: Portable OpenSSH Reporter: martin ➬ <bugzilla.mindrot.org>
Component: sshAssignee: Assigned to nobody <unassigned-bugs>
Status: NEW ---    
Severity: enhancement    
Priority: P5    
Version: 6.9p1   
Hardware: Other   
OS: Linux   

Description martin ➬ 2015-09-10 15:30:17 AEST
I have a roaming machine, sometimes available as machine.example.org and other times as machine.example.com. In order to be able to just "ssh machine", I currently have the following ProxyCommand in place:

  ProxyCommand bash -c "TARGETS=$(bash -c 'TRIES=machine.example.{org,com};
  eval fping -aAC1 -t100 $TRIES; eval fping6 -aAC1 -t100 $TRIES; echo %h : 9999'
  2>&1 | sed -rne 's, : ([[:digit:]]), @\1,p' | sort -t@ -k2n | sed -ne 's,
  .*,,p' | tr '\n' ','); nc -vq0 \${TARGETS%%%%,*} %p"

which essentially pings all DNS names and uses the respond times to pick the
best target.

I wish OpenSSH's client just let me do this implicitly. I am not talking about
CanonicalDomains — this would only try various names until one resolved in
DNS, whereas in my case, all names always resolve — but about an option e.g.

Host machine
  TryConnect %h.example.org %h.example.com

and it would then try to connect to both these names in parallel and once
a connect is successful, it would just kill off the other attempts. This would
be better than to do this in serial, as that might take too long.

Is this something to consider?