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

Github Action部署Web服务器时文件复制错误求助

问题排查:GitHub Action中appleboy/scp-action部署失败(Exit Code 11)

问题背景

使用GitHub Action推送main分支触发部署时,appleboy/scp-action抛出Process exited with status 11错误。本地通过WinSCP/SSH使用相同凭据可正常连接服务器,目标文件夹/httpdocs/action已配置全权限,且已开启ACTIONS_STEP_DEBUG=true,但仍无法获取足够排查信息。

Action配置代码

name: Test and Deploy

on:
  push:
    branches: [ main ]

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Deploy to webserver
      uses: appleboy/scp-action@master
      with:
        host: ${{ secrets.SERVER_HOST }}
        username: ${{ secrets.SERVER_USERNAME }}
        password: ${{ secrets.SERVER_PASSWORD }}
        source: "."
        target: "/httpdocs/action"

错误日志

##[debug]Evaluating condition for step: 'Deploy to webserver'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Deploy to webserver
##[debug]Loading inputs
##[debug]Evaluating: secrets.SERVER_HOST
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'SERVER_HOST'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: secrets.SERVER_USERNAME
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'SERVER_USERNAME'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: secrets.SERVER_PASSWORD
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'SERVER_PASSWORD'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run appleboy/scp-action@master
/usr/bin/docker run --name a5c76b983e5a3c391f4e43b5ab2922b38be258_f7934b --label a5c76b --workdir /github/workspace --rm -e "INPUT_HOST" -e "INPUT_USERNAME" -e "INPUT_PASSWORD" -e "INPUT_SOURCE" -e "INPUT_TARGET" -e "INPUT_PORT" -e "INPUT_TIMEOUT" -e "INPUT_COMMAND_TIMEOUT" -e "INPUT_KEY" -e "INPUT_KEY_PATH" -e "INPUT_PASSPHRASE" -e "INPUT_FINGERPRINT" -e "INPUT_USE_INSECURE_CIPHER" -e "INPUT_RM" -e "INPUT_DEBUG" -e "INPUT_STRIP_COMPONENTS" -e "INPUT_OVERWRITE" -e "INPUT_TAR_TMP_PATH" -e "INPUT_PROXY_HOST" -e "INPUT_PROXY_PORT" -e "INPUT_PROXY_USERNAME" -e "INPUT_PROXY_PASSWORD" -e "INPUT_PROXY_PASSPHRASE" -e "INPUT_PROXY_TIMEOUT" -e "INPUT_PROXY_KEY" -e "INPUT_PROXY_KEY_PATH" -e "INPUT_PROXY_FINGERPRINT" -e "INPUT_PROXY_USE_INSECURE_CIPHER" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_DEBUG" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/git_actions_example/git_actions_example":"/github/workspace" a5c76b:983e5a3c391f4e43b5ab2922b38be258
tar all files into /tmp/513600315/AvOsxxCiop.tar
scp file to server.
drone-scp error:  error copy file to dest: ***, error message: Process exited with status 11

2023/03/09 16:46:38 error copy file to dest: ***, error message: Process exited with status 11
##[debug]Docker Action run completed with exit code 1
##[debug]Finishing: Deploy to webserver

获取更多排查信息的方法

  • 开启scp-action内置debug模式:在部署步骤的with参数中添加debug: true,会输出scp命令执行的详细日志,包括连接协商、文件传输的具体过程。修改后的步骤示例:
    - name: Deploy to webserver
      uses: appleboy/scp-action@master
      with:
        host: ${{ secrets.SERVER_HOST }}
        username: ${{ secrets.SERVER_USERNAME }}
        password: ${{ secrets.SERVER_PASSWORD }}
        source: "."
        target: "/httpdocs/action"
        debug: true
    
  • 添加独立SSH测试步骤:在scp步骤前新增SSH连接测试,执行基础命令验证连接有效性、文件夹权限及当前用户身份,示例:
    - name: Test SSH connection and folder access
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.SERVER_HOST }}
        username: ${{ secrets.SERVER_USERNAME }}
        password: ${{ secrets.SERVER_PASSWORD }}
        script: |
          pwd
          ls -ld /httpdocs/action
          whoami
    
  • 检查服务器端SSH日志:查看服务器的SSH服务日志(通常路径为/var/log/auth.log或/var/log/secure),日志中会记录SSH连接、认证、文件操作的详细错误信息,比如SELinux限制、磁盘空间不足、文件系统权限问题等。
  • 缩小传输范围排查:临时修改source参数为单个文件(如source: "README.md"),排除是否因部分文件的特殊权限、过大体积或数量导致打包/传输失败。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 16:34:57