Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm getting an error when running your action #2

Open
maxacarvalho opened this issue Apr 9, 2020 · 11 comments
Open

I'm getting an error when running your action #2

maxacarvalho opened this issue Apr 9, 2020 · 11 comments
Labels
question Further information is requested

Comments

@maxacarvalho
Copy link

Hi,

I'm trying to use your action to deploy my project using Laravel Deployer but I'm getting an error and I'd like some help if you don't mind.

Here's the error that I see on Github Actions output:

Run atymic/[email protected]
  with:
    ssh-private-key: ***
    ssh-known-hosts: ***
    ssh-disable-host-key-checking: true
- Install Deployer [1/2]
- Install Deployer [1/2]
- Setup SSH [2/2]
- Install Deployer [1/2]
- Command failed with exit code 1: ssh-add - [2/2]
- Install Deployer [1/2]
- Command failed with exit code 1: ssh-add - [2/2]

➤ Executing task deploy:unlock

In Client.php line 103:
                                                                               
  [Deployer\Exception\RuntimeException (-1)]                                   
  The command "rm -f ***/.dep/deploy.lock" faile  
  d.                                                                           
                                                                               
  Exit Code: -1 (Unknown error)                                                
                                                                               
  Host Name: ***                                                      
                                                                               
  ================                                                             
  Host key verification failed.                                                

You can see that it fails when trying to verify the host key but I think it has to do to the fact that on the previous step it fails the command ssh-add.

Here's my action YAML file:

name: deploy
on:
  push:
    branches:
      - master

jobs:
  deploy:
    name: deploy to production
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/master'
    steps:
      - uses: actions/checkout@v1
      - name: Setup PHP
        uses: shivammathur/setup-php@master
        with:
          php-version: 7.4
          extensions: mbstring, bcmath
      - name: Composer install
        run: composer install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-suggest
      - name: Setup Deployer
        uses: atymic/[email protected]
        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
          ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
      - name: Run Deployment
        env:
          APP_HOST: ${{ secrets.APP_HOST }}
          APP_DEPLOY_PATH: ${{ secrets.APP_DEPLOY_PATH }}
          APP_DEPLOY_USER: ${{ secrets.APP_DEPLOY_USER }}
          APP_DEPLOY_DEFAULT: ${{ secrets.APP_DEPLOY_DEFAULT }}
        run: php artisan deploy production --verbose

I appreciate any help that you might be able to provide.

@atymic atymic added the question Further information is requested label Apr 10, 2020
@atymic
Copy link
Owner

atymic commented Apr 10, 2020

Hey :)

Looks like an issue with host keys:

 Host Name: ***                                                      
                                                                               
  ================                                                             
  Host key verification failed.                                                               

Check if you can deploy with ssh-disable-host-key-checking: true. If you can, there's an issue with the known hosts file your provided. Run the command in the readme, and update the secret.

@maxacarvalho
Copy link
Author

Hi @atymic

Thanks for your quick reply.
I already tried that option and it doesn't work.
Do you have any idea why the ssh-add is failing? That's where I think the problem lies. Since that's not happening the deployer step is failing. But I don't know why the ssh-add is returning a failed response.

@abhisheksarmah
Copy link

Hi @atymic

I am also having the Host key verification failed. issue.
Sometimes it shows Permission denied (publickey) error.

@jbelien
Copy link

jbelien commented May 8, 2020

I don't know it it's the exact same issue but I also struggle to connect via ssh.


Here is the log without ssh-disable-host-key-checking: true

Setup Deployer (26s)

- Setup SSH [2/2]
Run atymic/deployer-php-action@master
- Install Deployer [1/2]
- Install Deployer [1/2]
- Setup SSH [2/2]
- Install Deployer [1/2]
- Setup SSH [2/2]
- Install Deployer [1/2]
- Setup SSH [2/2]

Deploy (5s)
                                                                               
Run dep deploy sandbox -vvv
✈︎ Deploying master on sandbox
• done on [sandbox]
➤ Executing task deploy:prepare
[sandbox] > echo $0
[sandbox] < ssh multiplexing initialization
[sandbox] < Permission denied, please try again.
[sandbox] < Permission denied, please try again.
[sandbox] < [email protected]: Permission denied (publickey,password).

Error: Permission denied, please try again.
See https://github.com/geo6/mapper/runs/656492791?check_suite_focus=true


Here is the log with ssh-disable-host-key-checking: true

Setup Deployer (25s)

- EACCES: permission denied, open '/etc/ssh/ssh_config' [2/2]
Run atymic/deployer-php-action@master
- Install Deployer [1/2]
- Install Deployer [1/2]
- Setup SSH [2/2]
- Install Deployer [1/2]
- EACCES: permission denied, open '/etc/ssh/ssh_config' [2/2]
- Install Deployer [1/2]
- EACCES: permission denied, open '/etc/ssh/ssh_config' [2/2]

Deploy (2s)

##[error]Process completed with exit code 255.
Run dep deploy sandbox -vvv
✈︎ Deploying master on sandbox
• done on [sandbox]
➤ Executing task deploy:prepare
[sandbox] > echo $0
[sandbox] < ssh multiplexing initialization
[sandbox] < Host key verification failed.
➤ Executing task deploy:failed
• done on [sandbox]
✔ Ok [0ms]
➤ Executing task deploy:unlock
[sandbox] > rm -f /var/www/sandbox/source/mapper/.dep/deploy.lock
[sandbox] < ssh multiplexing initialization
[sandbox] < Host key verification failed.

Errors: EACCES: permission denied, open '/etc/ssh/ssh_config' + Host key verification failed.
See https://github.com/geo6/mapper/runs/656514158?check_suite_focus=true


I'm guessing there is as you said an issue with my SSH_KNOWN_HOSTS secret.
I run the ssh-keyscan rsa -t <server IP> but I have warnings, so I run ssh-keyscan -t rsa <server IP> and copy-pasted the content in my SSH_KNOWN_HOSTS secret.

With ssh-disable-host-key-checking: true, there seems to be a permission issue in atymic/deployer-php-action@master.

Thanks for your help !

@paulhennell
Copy link

I'm also seeing the same error:

➤ Executing task deploy:prepare
[deploy] > echo $0
[deploy] < ssh multiplexing initialization
[deploy] < Host key verification failed.

I get this same error with ssh-disable-host-key-checking: true set and without.

@robertotcestari
Copy link

Same here. It seems that ssh-disable-host-key-checking is making no difference!

@robertotcestari
Copy link

My solution:

  1. make sure that you copy the whole line at your known_hosts file (~/.ssh/known_hosts).
  2. make sure your ssh key is a PEM key and not an OPENSSH (check here https://github.com/marketplace/actions/install-ssh-key#ssh-failed-even-though-key-has-been-installed)

@Laca81
Copy link

Laca81 commented Jan 11, 2021

Same here. This ssh-disable-host-key-checking: true does not take any effect.

BUT! I made a mistake; I just copied the result from ssh-keyscan -t rsa <server IP> after the IP address of my server. When I also included the IP it works!

@bpolaszek
Copy link

Same here, I generated a new key, added it in SSH_PRIVATE_KEY secret, added the public one on my remote's authorized_keys, ensured I could connect from my computer with that key, copy/pasted the fingerprint into SSH_KNOWN_HOSTS.

Deployer yells:

Host key verification failed.

Disabling host key checking didn't help either. 🙁

@sluxzer
Copy link

sluxzer commented Mar 13, 2021

i'm having same issue, trying all solution above didn't work for me

@hastinbe
Copy link

hastinbe commented May 4, 2021

Same as others.. Not sure what the issue is but I switched to shimataro/ssh-key-action to handle setting up SSH and it works properly. Not to steer others away from your GH action but maybe there's something there that can help figure out the issue

Before I had the following setup:

      - name: Setup Deployer
        uses: atymic/deployer-php-action@master
        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
          ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }}

Using shimataro/ssh-key-action:

    - name: Setup SSH for YOUR_USER
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          name: id_rsa-YOUR_USER
          known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
          config: |
            Host HOSTNAME_OF_SERVER
              HostName HOSTNAME_OF_SERVER
              User YOUR_USER
              IdentityFile ~/.ssh/id_rsa-YOUR_USER

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

10 participants