简体   繁体   中英

Git Pull command in shell script without having to enter password manually?

I need a way off avoiding entering my password manually when a git pull command is executed in a build script I have.

I have tried the ssh keygen method and the git credentials caching method but both of them do not work for me.

So is there any way of somehow storing the password in the shell script somewhere, so the password prompt just uses the stored password, instead of waiting for me to enter the password explicitly and hitting enter.

Thanks guys.

I really think that you should fix the process git ssh keys, but if you really want to automate something, you can always use expect :

/usr/bin/expect <<EOD
spawn git pull
expect "password:"
send "this_is_my_password_unsafely_stored_in_a_bash_script\r"
interact
EOD
git config --global credential.helper "cache --timeout=2400"

You can change timeout value according to your need.

Also see: Is there a way to skip password typing when using https:// on GitHub?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM