1

I am using a script to update my system:

cd /opt/
chmod 600 /opt/updater/.ssh/.pk
ssh-agent bash -c 'ssh-add /opt/updater/.ssh/.pk; git stash; git pull origin master'
/opt/updater/bin/updater.sh

My problem is that if /opt/updater/.ssh/.pk us not readable or the ssh-key was changed, the process will get stuck like this:

  ssh-agent bash -c 'ssh-add /opt/RDE/rdeupdater/.ssh/.pk; git stash; git pull origin master;EX=$?;echo "-$EX" '
/opt/RDE/rdeupdater/.ssh/.pk: No such file or directory
No local changes to save
user@git's password:

How can I solve this from getting stuck? Expect isn't allowed on this system.

3

The trick is to have ssh immediately fail if it tries to do password authentication (thus always only do public/private key authentication).

You could set the environment variable GIT_SSH to a shell script to extend the normal ssh command to include -o "PasswordAuthentication no", but if you don't normally access the server where the gitrepository is located, you can also set in ~/.ssh_config:

Host server_with_remote_git_repo_name
    PasswordAuthentication no

and then override that if you ever need to access server_with_remote_git_repo_name with a password, by doing ssh -o "PasswordAuthentication yes" server_with_remote_git_repo_name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.