How do I provide passphrase with git fetch/pull in bash script. I really need to do it in a bash script, without using ssh-add or something like that. is it possible?
Provide passphrase to git in bash script
Asked Answered
I tryed ssh-agent and solution with SSH_ASKPASS but nothing worked, then I found a solution using http://expect.sourceforge.net/
Example(executed in shell):
pass="passwod"
/usr/bin/expect <<EOD
spawn git fetch origin $BRANCH
expect "Enter passphrase for key '/home/$USERNAME/.ssh/id_rsa': "
send "$pass\r"
expect eof
EOD
This worked lovely for me. My use case is executing a git pull in an enterprise CI setup that is not very flexible, so I need to provide the key passphrase in the CI interface/script. –
Monolith
© 2022 - 2024 — McMap. All rights reserved.
https://username:password@hostname/path/to/foo.git
. – Bridgetbridgetown