Carl Ponder
Carl Ponder

Reputation: 41

Testing ssh connection inside ssh_config file

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.

Upvotes: 1

Views: 224

Answers (0)

Related Questions