appleboy / ssh-action

GitHub Actions for executing remote ssh commands.
https://github.com/marketplace/actions/ssh-remote-commands
MIT License
4.66k stars 567 forks source link

ssh: handshake failed: read tcp *****:*** ->*****:***: read: connection reset by peer #292

Closed joris-Bourguet closed 4 months ago

joris-Bourguet commented 7 months ago

Hello, I'm trying to deploy my test app on server with githubactions but im encountering this error ssh: handshake failed: read tcp **: ->**:: read: connection reset by peer

The ssh key is in my server authorized keys and on my github https://github.com/settings/keys

The error happen in the deployment job, steps : Deploy using SSH

name: BUILD AND DEPLOY Laravel application

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

permissions:
  contents: read

jobs:
  build:
    name: Build project
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Validate composer.json and composer.lock
      run: composer validate --strict
    - name: Cache Composer packages
      id: composer-cache
      uses: actions/cache@v3
      with:
        path: vendor
        key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
        restore-keys: |
          ${{ runner.os }}-php-
    - name: Install dependencies
      run: composer install --prefer-dist --no-progress

  deployment:
    name: Deploy project
    environment: production
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name:  Checkout Repository
        uses: actions/checkout@v3

      - name: Deploy using SSH
        uses: appleboy/ssh-action@v1.0.0
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.REMOTE_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          port: ${{ secrets.PORT }}
          script: |
            cd ~/www/dev
            git pull origin main
            git status
            npm install --only=prod
          debug: true
joris-Bourguet commented 7 months ago

Update : My credentials are fine but my server firewall was blocking ssh entry, I allowed them and now it works