如何配置 capistrano 使用本地 rsa 密钥而不是 ssh 代理

发布于 2025-01-12 15:19:31 字数 1047 浏览 4 评论 0原文

我使用 capistrano 使用位于 ~/.ssh/id_rsa 的本地 rsa 密钥来部署我的项目。这总是按预期工作。

现在我在新计算机上安装了开发环境,现在当我运行 cap ...deploy 时,出现以下错误:

仅当 ED25519 可用时才支持 OpenSSH 密钥 (NotImplementedError) net-ssh 需要以下 gem 来支持 ed25519:

  • ed25519(>= 1.2,<2.0)
  • bcrypt_pbkdf(>= 1.0,<2.0)

我在谷歌搜索时发现了很多关于此的问题。大多数人建议运行 ssh-add ~/.ssh/id_rsa 来将密钥添加到 ssh 代理,有些人建议安装列出的两个 gem 并使用 ed25519 密钥。

我从那里了解到,capistrano 正在寻找存储在 ssh 代理中的密钥,然后回退到使用 ed25519 密钥。我需要的是 capistrano 只是使用位于 ~/.ssh/id_rsa 的本地 ssh 密钥。

我没有找到如何告诉 capistrano 使用本地 ssh 密钥 ~/.ssh/id_rsa 而不是 ssh 代理。

注释

我在 Windows 上使用 cygwin,并且安装永久 ssh 代理很棘手。我找到了冗长的说明,但没有让它发挥作用。

作为解决方法,我在 cap ...deploy 之前运行这些命令

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

长问题简短

如何配置 capistrano 或 ssh 来实现 cap ...deploy< /code> 在 ~/.ssh/id_rsa 选择 RSA 密钥来连接到远程服务器?

I used capistrano to deploy my project using my local rsa key located at ~/.ssh/id_rsa. This always worked as expected.

Now I installed the development environment on a new computer, and now when I run cap ... deploy, I get this error:

OpenSSH keys only supported if ED25519 is available (NotImplementedError)
net-ssh requires the following gems for ed25519 support:

  • ed25519 (>= 1.2, < 2.0)
  • bcrypt_pbkdf (>= 1.0, < 2.0)

I found plenty of questions about this while googling. Most suggest to run ssh-add ~/.ssh/id_rsa to add the key to the ssh agent, some suggest to install the two listed gems and use a ed25519 key.

I understand from there, that capistrano is looking for a key stored in the ssh agent, and then falls back to using an ed25519 key. What I need is that capistrano simply is using the local ssh key located at ~/.ssh/id_rsa.

I didn't find how to tell capistrano to use the local ssh key ~/.ssh/id_rsa instead of the ssh agent.

Notes

I am using cygwin on Windows, and the installation of a permanent ssh agent is tricky. I found lengthy instructions, but did not get it to work.

As a workaround, I run these commands before cap ... deploy

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

Long question short

How can I configure capistrano or ssh that way that cap ... deploy picks the RSA key at ~/.ssh/id_rsa to connect to the remote server ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少跟Wǒ拽 2025-01-19 15:19:31

这似乎是 SSH 问题,而不是 Capistrano 问题。首先是一些解释。

ssh-agent 将解密的密钥安全地存储在内存中,并且“没有合理且安全的方法来在重新启动/重新登录期间保留解密的密钥”

ssh-add< /code> 只是将这些密钥添加到您的代理

中 话虽如此,您的操作系统似乎在启动时不会自动在 ssh 代理上加载密钥,因此解决方案是自动执行此任务并将其设置为在启动时运行您开始会话。

我不是 Windows 用户,我没有任何方法来测试这个答案,但希望这能解决您的问题。

  1. 在桌面上右键单击“新建”> “快捷方式”
  2. 当询问“您想为什么项目创建快捷方式?”时,输入:“start-ssh-agent”(包含引号)。 “下一步”
  3. 然后单击“您想为快捷方式命名什么?”上的 。输入任意名称,例如:autoloadssh.exe(必须是可执行文件)。单击“保存”
  4. 复制此快捷方式并将其粘贴到位于“C:\Users[YOUR_USER]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup”的启动文件夹中
  5. 重新启动系统,加载后您应该能够运行“cap ...部署”

看看这个线程

This seems to be a SSH issue instead a Capistrano one. First some explanations..

ssh-agent stores securely your decrypted keys on memory and "there is no reasonable and safe way to preserve the decrypted keys among reboots/re-logins"

ssh-add just adds these keys to your agent

With that said, it seems that your operative system isn't loading your keys on your ssh agent automatically when it boot, so the solution is to automate this task and set it up to run when you starts your session.

I'm not a Windows user and I don't have any way to test this answer, but hope this solve your problem.

  1. On desktop, right click and "New" > "Shortcut"
  2. When it asks for "What item would you like to create a shortcut for?", enter this: "start-ssh-agent" (with quotation marks included). Then click "Next"
  3. On "What would you like to name the shortcut?" enter any name, for example: autoloadssh.exe (must be an executable). Click "Save"
  4. Copy this shortcut and paste it on your startup folder located at "C:\Users[YOUR_USER]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
  5. Reboot your system and after load you should be able to run "cap ... deploy"

Take a look to this thread.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文