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

Drone中SSH无密码认证配置报错求助

解决Drone SSH流水线无密码认证配置问题

Drone的SSH类型流水线强制要求指定认证方式,哪怕你本地已配置无密码登录,Drone运行环境(如Runner容器或进程)不会自动继承本地SSH密钥配置。要实现无密码认证,可通过以下两种方式解决:

方式一:用Drone Secrets传递已授权的SSH私钥

  1. 在Drone仓库的Secrets中添加你的SSH私钥(该私钥对应的公钥已在目标服务器drone用户的~/.ssh/authorized_keys中),命名为SSH_PRIVATE_KEY
  2. 修改.drone.yml引用该密钥:
kind: pipeline
name: copy-to-www
type: ssh

server:
  host: deployserver
  user: drone
  ssh_key:
    from_secret: SSH_PRIVATE_KEY

steps:
  - name: Build
    commands:
      # 替换为你的实际部署命令
      - scp ./build/* drone@deployserver:/var/www/html

方式二:开启SSH代理转发(仅适用于自托管Drone Runner)

如果你的Drone Runner运行在已配置好无密码登录目标服务器的机器上:

  1. 确保Runner机器上的~/.ssh/config已配置目标服务器的无密码登录规则:
Host deployserver
  User drone
  IdentityFile ~/.ssh/id_rsa # 已授权的私钥路径
  1. 在.drone.yml中启用代理转发:
kind: pipeline
name: copy-to-www
type: ssh

server:
  host: deployserver
  user: drone
  agent_forwarding: true

steps:
  - name: Build
    commands:
      # 替换为你的实际部署命令
      - rsync -avz ./build/ drone@deployserver:/var/www/html

注意:Drone的SSH流水线不支持完全不配置任何认证参数,必须指定password、ssh_key或开启agent_forwarding其中一种,这是流水线校验工具的强制要求。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 20:02:01