appleboy/ssh-action No such device or address error

Viewed 344

I'm trying to create an auto-deploy file for laravel project.

Here is my code of the yml file. jobs: deploy:

runs-on: ubuntu-latest

steps:
- name: Checkout
  uses: actions/checkout@v2 
- name: Deployment
  uses: appleboy/ssh-action@master
 
  with:
    host: ${{ secrets.SSH_HOST }}
    key: ${{ secrets.SSH_PRIVATE_KEY }}
    username: ${{ secrets.SSH_USERNAME }}
    script: |
      cd path-to-my-directory

      git pull
      php artisan migrate

git pull returns could not read Username for 'https://github.com': No such device or address error. But I sure that username, key, host are set properly. Can't solve the problem or find a similar issue with solution

1 Answers

If you set an SSH key, while your URL is an HTTPS one, said key would not be used. At all.

Instead, Git, in the GitHub Action, would try and get the credentials (username/password) for the private repository through HTTPS.

Plus, an SSH URL would use the username git anyway, alongside the private SSH key which allows the remote server to authenticate the actual user.

You can see here an example of a GitHub Action actually using an SSH URL:

on: [push]

jobs:
  try-ssh-commands:
    runs-on: ubuntu-latest
    name: SSH MY_TEST
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: test_ssh
        uses: ./
        with:
          ssh_key: ${{secrets.SSH_PRIVATE_KEY}}
          known_hosts: ${{secrets.SSH_KNOWN_HOSTS}}

If you are using HTTPS however, and as noted in the comments be the OP:

  • you need a PAT (Personal Access Token)
  • you need to store it: git config credential.helper store + git pull.
Related