2

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.

fulhamHead
  • 687
  • 1
  • 10
  • 23
  • You didn't mention if your repository url protocol is ssh or http. Depending on the protocol you have different ways to avoid entering password – rangalo Jul 24 '15 at 10:55
  • I am using ssh as my protocol, but I have tried ways using ssh keys to save me entering my password but none of them seemed to work. – fulhamHead Jul 24 '15 at 11:17

2 Answers2

3

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
enrico.bacis
  • 30,497
  • 10
  • 86
  • 115
  • brilliant that worked great thanks! the password is now hardcoded into my build script which may not be ideal in some cases but in this situation it is fine. thanks enrico. – fulhamHead Jul 24 '15 at 11:18
  • voted for explained security vulnerability in solution – milanchandna Jan 17 '17 at 06:12
0
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?

Community
  • 1
  • 1
Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133