Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I just got a new server for my website, and I'm trying to create a trunk in a folder where i can pull data from github.
That way I can easily get the latest version of the website, and copy the needed files to my www.

Git works fine, but then each time I do a:

git pull origin master

It asks me for a password! I want to be able to update git via a script, or even via PHP later on. So that I can update my server automatically. I've spend a few hours trying to figure out how to save the password but I couldn't, this is why I need your help.

I have followed a few instructions here:
http://help.github.com/ssh-key-passphrases/
But it didn't work.

I am SSHing from Windows to my machine using Putty. The server is a CentOS.

Now that I have added the script in ~/.bashrc as the tutorial told me to do, each time I connect with Putty I have a new line saying:

Could not open a connection to your authentication agent.
share|improve this question
    
one thing i did find, if I write this in Putty: exec ssh-agent bash it asks me for the password, and doesn't ask until I restart Putty. The problem is when I restart it forgets it, and also if I would like to run this with another program (PHP) it wouldn't work. –  xtrimsky Dec 2 '11 at 4:40
    
is this a private github repository or public? –  lunixbochs Dec 2 '11 at 7:47
add comment

1 Answer

up vote 1 down vote accepted

Try using expect. You can automatically supply the password to git through an automation script.

Just make sure your script has tight permissions -having plaintext passwords in scripts is usually Bad Idea™.

Edit:

Since I can't write code properly in the comment section below, you could write something like this:

#!/usr/bin/env expect
set password "<your-password>"
spawn /usr/bin/git pull
expect "<exact passphrase>"
send "$password\r"
share|improve this answer
    
expect was something i tried using too but It didn't work. This is how I did it: yum install expect (on centos) (it installed stuff and worked) And then in my batch script after git pull I entered expect "Enter passphrase...: (don't remember the exact phrase), and then entered: send: "mypassword". Am I doing something wrong ? –  xtrimsky Dec 2 '11 at 17:13
    
Check again the edited the answer. –  dkaragasidis Dec 2 '11 at 18:50
    
Ok so I've modified my file update.sh to look like this: #!/usr/bin/env expect set password "wei534kfer3" spawn /usr/local/bin/git pull origin master expect "Enter passphrase for key '/root/.ssh/id_rsa':" send "$password\r" I then executed: expect update.sh It shows something like that in my bash: ` spawn /usr/local/bin/git pull origin master Enter passphrase for key '/root/.ssh/id_rsa': [root@u15927644 trunk]#` (in almost a single line), and does not execute the pull request :(. No error. –  xtrimsky Dec 3 '11 at 2:56
    
oh nevermind I made it work, thanks! :) –  xtrimsky Dec 3 '11 at 3:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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