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

 ̄綄美尐妖づ 提交于 2019-11-30 23:44:11

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!