I have a problem for make a auto pull for a git repository. I explain my situation : i have 2 sever on linux (Debian), one for the repos (dev01) and another one for make documentation with doxygen (dev02). I make a script in bash to run doxygen every day and it's work fine.
The next step is to make some git pull on dev02 every day to pull repos on dev01. I try to make a script but when i make a git pull on dev02, it always ask me for dev01 password like this :
root@dev02:/repos# git pull
git@dev01's password:
I search for a solution on net and found something (expect) to make a script :
#!/usr/bin/env expect
cd /repos/repos_name
set password "git_password"
spawn /usr/bin/git pull
expect "git@dev01's password:"
send "$password\r"
It runs but do nothing… I found some solutions on web but all i try doesn't works. Maybe with Linux i can do other thing's to resolve it but I just begin on this OS.
How can i resolve this problem ?
Thanks
Best Answer
From the
git@dev01
, I'm guessing that you are pulling over SSH. Therefore you can use the same methods as for general passwordless SSH – specifically, public-key authentication. How to set it up has been described in great detail across many websites and tutorials, but here's the short summary:On the client, create a keypair using
ssh-agent
or PuTTYgen.(In this case,
root@dev02
is the client, andgit@dev01
is the server.)Copy the public key to the server, into the
~/.ssh/authorized_keys
file.(Copy it from the
~/.ssh/id_rsa.pub
file, or the "OpenSSH Public Key" text from PuTTYgen.)Run
ssh -v user@server
and make sure it shows the key being used: