scp-action: drone-scp error: error copy file to dest: ***, error message: Process exited with status 142

See logs:

Run appleboy/scp-action@master
  with:
    source: .
    target: /var/www/data
    port: 22
    timeout: 30s
    command_timeout: 10m
    use_insecure_cipher: false
    rm: false
    debug: false
    strip_components: 0
    overwrite: false
    proxy_port: 22
    proxy_timeout: 30s
    proxy_use_insecure_cipher: false
  env:
    HOST: ***
    USERNAME: ***
    KEY: ***
/usr/bin/docker run --name e28490203383e4abf4401eb8983ad2d069cbb8_d83965 --label e28490 --workdir /github/workspace --rm -e HOST -e USERNAME -e KEY -e INPUT_SOURCE -e INPUT_TARGET -e INPUT_HOST -e INPUT_PORT -e INPUT_USERNAME -e INPUT_PASSWORD -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_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_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_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -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/data/data":"/github/workspace" e28490:203383e4abf4401eb8983ad2d069cbb8
tar all files into /tmp/116532002/btkjHJuSID.tar
scp file to server.
drone-scp error:  error copy file to dest: ***, error message: Process exited with status 142

2021/11/11 09:16:15 error copy file to dest: ***, error message: Process exited with status 142

This is config:

name: dashboard-backend

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  deployment:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Copy file via scp
      uses: appleboy/scp-action@master
      env:
        HOST: ${{ secrets.HOST }}
        USERNAME: ${{ secrets.USERNAME }}
        KEY: ${{ secrets.SSHKEY }}
      with:
        source: "."
        target: "/var/www/data"

    - name: Executing remote  command
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.HOST }}
        USERNAME: ${{ secrets.USERNAME }}
        PORT: ${{ secrets.PORT }}
        KEY: ${{ secrets.SSHKEY }}
        script: |
          whoami
          cd /var/www/data
          sh run_prod.sh
          

Can you please confirm that? I am not clear what is the issue?

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 2
  • Comments: 25 (4 by maintainers)

Most upvoted comments

I had a chance to deal with that error today, so guys, possible causes of the error:

  • scp do not create a folder by itself, so be sure your target folder exist;
  • the storage is full;
  • user’s insufficient permissions in target directory;
  • your user does not have a home directory (most likely the action first scps the file into the user’s home directory, and then performs a move);

the last one worked for me.

Hope this helps, good luck everyone! 🤟

same problem I think the problem is /var/www does not exist on my machine or my user does not have root permission I just add a normal user or Could not chdir to home directory /home/my user name: No such file or directory

jobs:
  deploy_to_server:
    name: Deploying to Server
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: copy file via ssh password
        uses: appleboy/scp-action@v0.1.4
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}
          port: ${{ secrets.PORT }}
          source: ./
          target: /var/www/app

update with this it work for me what I do and fixed for me I add my user to the sudo er but did not success I try to add manually /var/www/app folder and test it not work ( think due to permission) so i go to some public places

sudo mkdir /home/my_user_name
sudo chown -R my_user_name:my_user_name /home/my_user_name
sudo chmod 700 /home/my_user_name
sudo usermod -d /home/my_user_name my_user_name

sudo mkdir /home/my_user_name sudo chown -R my_user_name:my_user_name /home/my_user_name sudo chmod 700 /home/my_user_name sudo usermod -d /home/my_user_name my_user_name

then I change the location where I send my file instead of /var/www/app to /home/my_user_name/app and before using scp i create the folder with connecting by ssh and send this command

  make_dir_for_app:
    name: Make a directory for the app
    runs-on: ubuntu-latest
    steps:
      - name: executing remote ssh commands using password
        uses: appleboy/ssh-action@v0.1.10
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}
          port: ${{ secrets.PORT }}
          script: |
            rm -r /home/my_user_name/app          
            mkdir -p /home/my_user_name/app          
            chmod 755 /home/my_user_name/app     
            cd /home/my_user_name/app  
            ls -la

update2 does not need this ssh and create a folder too if your permission is correct scp can create the folder my final config is

  deploy_to_server:
    name: Deploying to Server
    # needs: [make_dir_for_app]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v35
        with:
          since_last_remote_commit: true
          separator: ","

      - name: copy file via ssh password
        uses: appleboy/scp-action@v0.1.4
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}
          port: ${{ secrets.PORT }}
          source: ./
          target: /home/${{ secrets.USERNAME }}/app

@appleboy it’s not a bug from your side and it’s a server config problem

@matheusfischer0 Please post your config.

The wrong username was the cause of error 142 for me