I'm working on a Bash script that makes an SSH connection via git at a given point during the script's actions. I'm trying to gracefully handle some errors that can occur, stopping the script before it ends up failing part of the way through.
At one point it runs a command like git push
which initiates a push over SSH. There's a chance that this will connect to a new host for the first time, which leads to an interactive prompt verifying the validity of the host.
RSA key fingerprint is 96:a9:23:5c:cc:d1:0a:d4:70:22:93:e9:9e:1e:74:2f.
Are you sure you want to continue connecting (yes/no)? yes
I'm looking for ideas on how to either avoid the SSH prompt or fail the script early if the SSH host hasn't been approved by the user before.
I took a look at this question. The argument could be made that this question is a duplicate of that, but the solutions listed there don't apply to my situation. I'd prefer to detect that the SSH connection can't be made without the prompt and fail in that case.
StrictHostKeyChecking=no
is exactly what you want. You could try redirectingstdin
to git eggit pull < /dev/null