How to git pull without asking password?
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:debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/grawity/.ssh/id_global debug1: Server accepts key: pkalg ssh-rsa blen 535 debug1: Authentication succeeded (publickey).
Related videos on Youtube
Algorys
Make some Network Administration, Integration, python, java. I also create : Sysadmin.cool
Updated on September 18, 2022Comments
-
Algorys over 1 year
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
-
Algorys over 9 yearsYes i have already make this method but it still ask me for a password. I have this result when i make ssh -v git@dev01 debug1: Next authentication method: publickey debug1: Offering RSA public key: /root/.ssh/id_rsa.pub debug1: Authentications that can continue: publickey,password debug1: Next authentication method: password git@dev01's password:
-
user1686 over 9 years@mestra: that means the server is rejecting the key; did you add it to the right file?
-
Algorys over 9 yearsI'm daft : my files was called authorized.keys and not authorized_keys.... so it sure that will not works. Sorry for lost your time, it was just under my eyes since 1 weeks :'(