appleboy / scp-action

GitHub Action that copy files and artifacts via SSH.
https://github.com/marketplace/actions/scp-command-to-transfer-files
MIT License
1.14k stars 134 forks source link

ssh.ParsePrivateKey: ssh: no key found error [Solved] #118

Closed MehmetKaranlik closed 1 year ago

MehmetKaranlik commented 1 year ago

Disclaimer : Due to my error i ended up opening this issue in other appleboy repo just moving here.

Hello im trying to upload my backend executable to server but getting this error at this step.

Note : Few days ago it was working without getting any upgrade on this part.

tar all files into /tmp/RgranDeiYJ.tar.gz
2023/04/16 00:33:41 ssh.ParsePrivateKey: ssh: no key found
remote server os type is unix
2023/04/16 00:33:41 ssh.ParsePrivateKey: ssh: no key found

And i have correct key with included begin and end parts.

It fails on deploy stage of the workflow file i provided below.


env:
  KEY: '${{ secrets.EC2_KEY }}'
  HOST: '${{ secrets.EC2_HOST }}'
  USERNAME: '${{secrets.EC2_USERNAME}}'  

jobs:
  build:

    runs-on: ubuntu-latest
    steps:

    - uses: actions/checkout@v3  
    - name: Setup Go
      uses: actions/setup-go@v2
    - name : build
      run: GOOS=linux GOARCH=amd64 go build -o zirva
    - name: deploy
      uses: appleboy/scp-action@master
      with:
        host: $HOST
        username: $USERNAME
        key: $KEY
        source: zirva
        target: /home/ubuntu
    - name: register to host

      run: |
          mkdir -p ~/.ssh/
          echo "$KEY" > ~/.ssh/github-actions-key
          chmod 600 ~/.ssh/github-actions-key
          cat >>~/.ssh/config <<END
          Host ec2
            HostName $HOST
            User $USERNAME
            IdentityFile ~/.ssh/github-actions-key
            StrictHostKeyChecking no
          END
    - name: connect to server
      run: ssh ec2 sudo service restarter restart
MehmetKaranlik commented 1 year ago

Fixed by this https://github.com/appleboy/ssh-action/issues/243#issuecomment-1510137896 Thanks @appleboy