How to git pull without asking password?

11,379

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:

  1. On the client, create a keypair using ssh-agent or PuTTYgen.

    (In this case, root@dev02 is the client, and git@dev01 is the server.)

  2. 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.)

  3. 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).
    
Share:
11,379

Related videos on Youtube

Algorys
Author by

Algorys

Make some Network Administration, Integration, python, java. I also create : Sysadmin.cool

Updated on September 18, 2022

Comments

  • Algorys
    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
    Algorys over 9 years
    Yes 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
    user1686 over 9 years
    @mestra: that means the server is rejecting the key; did you add it to the right file?
  • Algorys
    Algorys over 9 years
    I'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 :'(