I want to check if I can ssh to a list of hosts by only using keys.
This answer suggests doing the following:
exec ssh -o BatchMode=yes "user@host" true
... which should connect to the host, run true
and return its exit status.
On my Ubuntu machine it doesn't work. Something in the above command forces the terminal to close. What did I do wrong?
(Also, since I am required to use the -l
option to pass my username, the regular command would be: ssh -l user host
. Will exec
interpret this as something else?)
exec
causes the current shell to be replaced byssh
. Whenssh
exits, your terminal does as well. Just useto return to your shell after
ssh
completes.