Bug 2462 - Option to try connectiing to multiple DNS names
Summary: Option to try connectiing to multiple DNS names
Status: NEW
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 6.9p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-10 15:30 AEST by martin ➬
Modified: 2015-09-10 15:30 AEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?