appleboy / ssh-action

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

i/o timeout #309

Closed irakli-ika closed 1 month ago

irakli-ika commented 7 months ago

Hello, I try to deploy a project with Github to Digitalocean, I use ssh-action@v1.0.3 and have this issue ***:22: i/o timeout. I saw old solutions with port: 8000 but it returns the same error ***:8000: i/o timeout, can you help me fix this issue?

appleboy commented 7 months ago

Please post your all workflow. Thanks.

irakli-ika commented 7 months ago

Please post your all workflow. Thanks.

This is my workflow at the moment

`name: Laravel

on: push: branches: [ "main" ]

jobs: laravel-tests:

runs-on: ubuntu-latest

steps:
  - name: Deploy Laravel App
    uses: appleboy/ssh-action@v1.0.3
    with:
      host: ${{secrets.SSH_HOST}}
      key: ${{secrets.SSH_PRIVATE_KEY}}
      username: ${{secrets.SSH_USERNAME}}

      script: |
        mkdir www
        cd www
        mkdir html
        cd html
        git clone https://github.com/irakli-ika/reponamehere.git`
felipe3dfx commented 7 months ago

I have the same error:

  deploy:
    runs-on: self-hosted
    environment: production
    needs: [test]
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          script_stop: true
          script: |
            cd ${{ github.event.repository.name }}
            git fetch
            git checkout '${{ github.sha }}'
            bash bin/main_run

image

appleboy commented 7 months ago

@felipe3dfx Your SSH Server OS version and make sure your firewall policy?

ariwijayaikd commented 7 months ago

Please post your all workflow. Thanks.

This is my workflow at the moment

`name: Laravel

on: push: branches: [ "main" ]

jobs: laravel-tests:

runs-on: ubuntu-latest

steps:
  - name: Deploy Laravel App
    uses: appleboy/ssh-action@v1.0.3
    with:
      host: ${{secrets.SSH_HOST}}
      key: ${{secrets.SSH_PRIVATE_KEY}}
      username: ${{secrets.SSH_USERNAME}}

      script: |
        mkdir www
        cd www
        mkdir html
        cd html
        git clone https://github.com/irakli-ika/reponamehere.git`

have you try add step to add vpn connection so at least you can ping the target server?

ariwijayaikd commented 7 months ago

@felipe3dfx did your self runner can ssh to the target host? edit: because I have the same issue, I can connect to target from the selfhosted runner server, but get timeout form ssh appleboy

irakli-ika commented 7 months ago

Please post your all workflow. Thanks.

This is my workflow at the moment `name: Laravel on: push: branches: [ "main" ] jobs: laravel-tests:

runs-on: ubuntu-latest

steps:
  - name: Deploy Laravel App
    uses: appleboy/ssh-action@v1.0.3
    with:
      host: ${{secrets.SSH_HOST}}
      key: ${{secrets.SSH_PRIVATE_KEY}}
      username: ${{secrets.SSH_USERNAME}}

      script: |
        mkdir www
        cd www
        mkdir html
        cd html
        git clone https://github.com/irakli-ika/reponamehere.git`

have you try add step to add vpn connection so at least you can ping the target server?

Thanks for the feedback, I researched and saw connect with a docker image, is the correct way? when I try this way it returns Failed to open /dev/net/tun Error: 2. No such file or directory. can you help me with how can I connect with a VPN?

ariwijayaikd commented 7 months ago

@irakli-ika depend on your case, but for me I use ovpn, so the jobs can go like this

jobs:
  deployment:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - name: Make VPN USER
        run: |
          echo "${{ secrets.USERVPN }}" > .github/workflows/vpn
      - name: Make Client VPN File
        run: |
          echo "${{ secrets.CLIENTVPN }}" > .github/workflows/client.ovpn
      - name: Install Open VPN
        run: |
          sudo apt-get update
          sudo apt-get install openvpn
      - name: Connect VPN
        run: |
          sudo openvpn --config .github/workflows/client.ovpn --daemon
      - name: Build on server
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}
          port: ${{ secrets.PORT }}
          script: |
            yourscript
      - name: kill vpn
        if: always()
        run: sudo killall openvpn
felipe3dfx commented 7 months ago

@felipe3dfx Your SSH Server OS version and make sure your firewall policy?

I don't have any restrictions on the firewall for port 22.

appleboy commented 7 months ago

@felipe3dfx Where is your server? in Linode or any other cloud provider?

ariwijayaikd commented 7 months ago

I am experiencing a similar issue. I am using a GitHub self-hosted runner and from that server I was able to SSH into the target server. However, when using the appleyboy ssh-action, I am getting timeout response.

felipe3dfx commented 7 months ago

@felipe3dfx Where is your server? in Linode or any other cloud provider?

@appleboy I use Linode (Runner included)

FerroEduardo commented 3 months ago

I'm facing a similar problem where the pipeline times out when connecting to my EC2, whether using nc or appleboy/ssh-action. However, it works when connecting from my local machine.

1, 2

Edit: Tried to contact GitHub support, but nothing could be done by them. I was able to fix by changing my IPV4 to a new one

appleboy commented 1 month ago

@irakli-ika Any feedback? Please reopen the issue if you continue to encounter the same problem.