Using cygwin ssh-agent is running but git is still prompting for passphrase

后端 未结 1 564
陌清茗
陌清茗 2021-01-07 06:57

I\'m using cygwin as my terminal on Windows 7. I have found several suggestions to run ssh-agent in cygwin so I don\'t have to enter my password every time I run a git fetch

相关标签:
1条回答
  • 2021-01-07 07:15

    The problem is still remain. Seems it is related to the different paths and hasn't been fixed yet. You may consider to use expect as an alternatif to ssh-agent for login with passphrase interaction.

    In Linux it use to be installed like this:

    $ sudo apt-get update
    $ apt-get install --assume-yes --no-install-recommends apt-utils expect 
    

    In cygwin you may find it under Tcl:

    Here is a simple step on how to use it.

    Create a file, lets locate it and name ~/.expect_push

    #!/usr/bin/expect -f
    spawn git push origin master
    expect "Username for 'https://github.com':"
    send "<username>\n";
    expect "Password for 'https://<username>@github.com':"
    send "<password>\n";
    interact
    

    Change the above <username> and <password> to your login id with following notes:

    • Modify the contents follow precisely to your git login interaction.
    • If your <password> contain the char $ put it as \$ otherwise the authentication will be failed.
    • For example if your password mypa$$word then put <password> as mypa\$\$word.

    Create another file ~/.git_push

    #!/usr/bin/bash
    git remote set-url origin git@github.com:<username>/<repo>.git
    git add .
    git commit -m "my test commit using expect"
    expect ~/.ssh/.expect_push
    

    Make them executable and create symlink in /bin

    $ chmod +x ~/.expect_push
    $ chmod +x ~/.git_push
    $ cd /bin
    $ ln -s ~/.git_push push
    

    Then you can push to the remote without need to fill in username and password or passphrase

    $ cd /path/to/your/git/folder
    $ push
    
    0 讨论(0)
提交回复
热议问题