1

I'm working with a funny setup where the User ID on a remote cluster changes every 24-hours. I don't want to have to do either of these

(1) Re-enter this ID every time I log in, using ssh NewID@thathost or ssh -l NewID thathost.

(2) Edit the ~/.ssh/config entry for the host each day.

What I'm trying to do is write a script that prompts for a UserID, and stores the information into a temporary config-file. This entry in the ~/.ssh/config doesn't quite work, though:

Match originalhost thathost !exec "ssh -T -F ~/.ssh/HACK/config thathost true" exec "~/.ssh/HACK/queryID thathost"
include ~/.ssh/HACK/config

Host thathost
include ~/.ssh/HACK/config

I'm expecting the Match line to try connecting, and if it doesn't work, then call the query-script to re-generate the temporary config. The problem is that the ssh operation seems to always set an exit-code of 255 (even though it returns an exit-code of 0 when I try it on the command-line) so the queryID script gets invoked every time.

I get the impression that calls to ssh may not be allowed inside the ssh-config, is this true? Note that there's no recursion going on here, since the embedded sshoperation is not using the same config-file.

  • I can re-work this to go by the *age* of the provisional config-file, so please refrain from suggesting that (although a 1-line solution not requiring wrapper-scripts would be interesting). – Carl Ponder Feb 20 '23 at 16:04
  • One thing I have to get off my mind here -- if I'd designed the way the ssh_config files worked, I would allow duplication in the rule-targets and then just have it use the first rule that makes a successful connection. Note that it would simplify the use of ProxyCommands, since it could just work down a list of proxy setups until it found the one that worked. – Carl Ponder Feb 20 '23 at 16:06

0 Answers0