我正在尝试使用 Capistrano 3.3.5(以及 net-ssh 3.2.0)部署 Drupal 应用程序。我的部署工作站是运行 git-bash 的 Windows。我还启动了 ssh-agent,并为我的私钥运行 ssh-add。
然后我跑了:
> cap development deploy
它要求我输入私钥的密码。
Enter passphrase for C:/Users/jgodse/.ssh/id_rsa: my_password
当我输入“my_password”作为我的 SSH key 密码时,它挂起。我按了 CTRL-C,然后它说:
bash: my_password: command not found
然后我尝试了:
> cap development --dry-run
按几次回车键后,我得到了一份试运行日志。前几行如下所示:
$ cap development deploy --dry-run
There was a problem tracking statistics, please report to https://github.com/capistrano/stats
INFO [4b085395] Running /usr/bin/env mkdir -p /tmp/myapp/ as <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e89d8a9d869c9da89f9f9fc68591899898c68b8785" rel="noreferrer noopener nofollow">[email protected]</a>
DEBUG [4b085395] Command: /usr/bin/env mkdir -p /tmp/myapp/
INFO [b5f607a2] Running /usr/bin/env #<StringIO:0x3b9e4d0> /tmp/myapp/git-ssh.sh as <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e89d8a9d869c9da89f9f9fc68591899898c68b8785" rel="noreferrer noopener nofollow">[email protected]</a>
DEBUG [b5f607a2] Command: /usr/bin/env #<StringIO:0x3b9e4d0> /tmp/myapp/git-ssh.sh
INFO [c0895cc9] Running /usr/bin/env chmod +x /tmp/myapp/git-ssh.sh as <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="512433243f2524112626267f3c283021217f323e3c" rel="noreferrer noopener nofollow">[email protected]</a>
然后我调整了Capfile以添加语句:
set :ssh_options, {:forward_agent => true}
没有变化。
然后我升级到 capistrano 3.5.0,并卸载 capistrano-stats,并将版本锁定为 3.5.0。
> cap development deploy --dry-run
我得到:
00:00 git:wrapper
01 mkdir -p /tmp/myapp/
02 #<StringIO:0x28c7238> /tmp/myapp/git-ssh.sh
03 chmod +rx /tmp/myapp/git-ssh.sh
这告诉我 git:wrapper 任务可能很麻烦。然后我跑了:
> cap development git:wrapper
我得到了:
00:00 git:wrapper
01 mkdir -p /tmp/myapp/
Enter passphrase for C:/Users/me/.ssh/id_rsa:
当我输入密码时,我得到了与之前相同的结果。然后我做了:
> cap development git:wrapper --dry-run
我得到了:
00:00 git:wrapper
01 mkdir -p /tmp/myapp/
02 #<StringIO:0x28e2448> /tmp/myapp/git-ssh.sh
03 chmod +rx /tmp/myapp/git-ssh.sh
此时看起来 git:wrapper 任务不起作用,可能是因为步骤 2 中有这个 StringIO: 东西,它看起来像一个 Ruby 对象 id 而不是实际的 Bash 命令。或者也可能是别的东西。
是否有任何方法可以解决此问题,以便我的部署不会错误地要求我输入密码?
最佳答案
您可能需要设置 SSH 代理,以便在部署时不需要您的 key 密码。
Capistrano 文档包含执行此操作的详细信息:http://capistranorb.com/documentation/getting-started/authentication-and-authorisation/
简短的版本可能类似于:
运行:
eval "$(ssh-agent -s)"
ssh-add
# It'll prompt you for your password here.
cap dev deploy # Or whatever you run to execute Capistrano.
此时,您应该能够在此 shell 中运行 Capistrano,而不会提示输入密码。
如果这有用,您可能需要了解如何设置 shell 以跨终端共享 ssh-agent session 。
关于git - 卡皮斯特 pull 诺 git :wrapper keeps asking for ssh passphrase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38249743/