You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu升级后Capistrano 3部署需输入SSH用户密码问题

Capistrano部署SSH认证故障(Ubuntu升级后)

问题描述

我有一个Rails应用,此前通过Capistrano 3可正常部署到Ubuntu服务器。昨晚执行do-release-upgrade完成服务器升级,当前系统信息:

Linux my-server 5.15.0-47-generic #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

本地通过Mac终端使用id_rsa密钥SSH登录服务器完全正常:

ssh user@my-server.example.com
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-47-generic x86_64)

但使用Capistrano部署时,系统要求输入SSH用户密码(而非id_rsa密钥认证):

cap production deploy
user@my-server.example.com's password:

尝试执行ssh-copy-id重新上传密钥,结果提示所有密钥已存在于远程系统:

ssh-copy-id user@my-server.example.com     
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
                (if you think this is a mistake, you may want to use -f option)

值得注意的是,前一天我还成功完成了9次部署:

ls -lia rails/releases/ | grep 20220913 | wc -l
9

服务器并未启用SSH密码登录,现需解决此问题以恢复正常的SSH通信。

更新信息

怀疑问题与SSH代理转发有关,使用capistrano-ssh-doctor工具检查后得到如下报告:

SSH agent forwarding report

  1. [success] repo_url setting ok
  2. [success] ssh private key file exists
  3. [success] ssh-agent process seems to be running locally
  4. [success] ssh-agent process recognized by ssh-add command
  5. [success] ssh private keys added to ssh-agent
  6. [success] application repository accessible from local machine
  7. [success] all hosts using passwordless login
  8. [success] forward_agent ok for all hosts
  9. [success] ssh agent successfully forwarded to remote hosts
  10. [error] It seems Capistrano cannot access application git repository from these hosts: my-server.example.com
    Actions:
    • make sure all the previous checks pass. That should make this one work too.

It seems SSH agent forwarding is not set up correctly. Follow the suggested steps described in error messages. Errors (if more than one) are ordered by importance, so always start with the first one.

登录服务器后可成功克隆代码仓库,参考相关信息后,怀疑需要修改:repo_url配置,准备尝试此方案。


内容的提问来源于stack exchange,提问作者Besi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 04:45:41