ssh-action icon indicating copy to clipboard operation
ssh-action copied to clipboard

ssh: handshake failed on every attempt

Open Cabalist opened this issue 4 years ago • 99 comments

Hey there,

I'm stuck and wasn't able to find a solution in reading previous issues. I keep getting the following error: 2020/08/29 01:19:13 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

Here is my YAML:

name: Deploy branch to staging

on:
  push:
    branches: [ develop ]


jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: executing remote ssh commands
        uses: appleboy/ssh-action@master
        with:
          script_stop: true
          host: ${{ secrets.NEWDEV_HOST }}
          username: ${{ secrets.NEWDEV_USERNAME }}
          key: ${{ secrets.NEWDEV_SSH_KEY }}
          port: ${{ secrets.NEWDEV_SSH_PORT }}
          script: whoami

My ssh key is a pem file:

-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----

The correct values are in .ssh/authorized_keys on the remote server. I am able to ssh from multiple other machines using this key. There is no passcode.

I'm stumped! This is on EC2 if that makes a difference.

Cabalist avatar Aug 29 '20 01:08 Cabalist

https://github.com/appleboy/ssh-action#setting-up-ssh-key

appleboy avatar Aug 29 '20 14:08 appleboy

I just followed those steps exactly (adding another key).

I get the same error on the Github action page. I'm able to log in fine using SSH from the terminal using that newly created key.

I must be missing something else. I don't believe it is Firewall related as SSH does respond and gives the handshake failed response. The key works from the ssh on the terminal when I use ssh -i github_deploy_id_rsa [email protected]

Just checking the basics here:

host is the dns name of the server (for example newdevsite.example.com) username is the ssh username (my username does have a hyphen in it ec2-user) key is the text of the private keyfile. No encoding just copied and pasted. port is 22 (I tried leaving this off since it is the default but that made no difference)

I'm not sure what else could be going wrong. Hmmm

Cabalist avatar Aug 31 '20 21:08 Cabalist

I got the same error

image

My action file

name: deploy

on:
  push:
    branches: [ master ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Connect and run Scripts
        uses: appleboy/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          HOST: ${{ secrets.HOST }}
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.PRIVATE_KEY }}
          port: ${{ secrets.PORT }}
          script: |
            whoami
            echo "$HOST"
            ls -a

mcameloa avatar Sep 11 '20 03:09 mcameloa

I just resolve the issue my RSA PRIVATE KEY was incomplete Try to run cat ~/.ssh/id_rsa

Thx.

mcameloa avatar Sep 11 '20 03:09 mcameloa

@militem-code Thanks! However you got the ParsePrivateKey: ssh: invalid openssh private key format error which is helpful. Unfortunately I get none of that. I'm able to confirm my key is correct from the command line. There is something else going on

executing remote ssh commands1s proxy_use_insecure_cipher: false Run appleboy/ssh-action@master /usr/bin/docker run --name e5ae592eecc69186d449d19429204e230021df_e58eb3 --label e5ae59 --workdir /github/workspace --rm -e INPUT_SCRIPT_STOP -e INPUT_HOST -e INPUT_USERNAME -e INPUT_KEY -e INPUT_PORT -e INPUT_SCRIPT -e INPUT_DEBUG -e INPUT_PASSPHRASE -e INPUT_PASSWORD -e INPUT_SYNC -e INPUT_USE_INSECURE_CIPHER -e INPUT_CIPHER -e INPUT_TIMEOUT -e INPUT_COMMAND_TIMEOUT -e INPUT_KEY_PATH -e INPUT_FINGERPRINT -e INPUT_PROXY_HOST -e INPUT_PROXY_PORT -e INPUT_PROXY_USERNAME -e INPUT_PROXY_PASSWORD -e INPUT_PROXY_PASSPHRASE -e INPUT_PROXY_TIMEOUT -e INPUT_PROXY_KEY -e INPUT_PROXY_KEY_PATH -e INPUT_PROXY_FINGERPRINT -e INPUT_PROXY_CIPHER -e INPUT_PROXY_USE_INSECURE_CIPHER -e INPUT_ENVS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/xxx/xxx":"/github/workspace" e5ae59:2eecc69186d449d19429204e230021df ======CMD====== whoami ======END====== ======ENV====== 2020/09/11 19:43:51 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

======END======

Cabalist avatar Sep 11 '20 20:09 Cabalist

I an confirm this error. All of a sudden it started to fail. Nothing has changed on the secrets

Siedlerchr avatar Sep 17 '20 12:09 Siedlerchr

Yea. I'm stumped on this too, can't find what is wrong

Oliyy avatar Sep 19 '20 00:09 Oliyy

I'm also unable to get it to work. Getting 2020/09/20 20:24:23 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

timahrentlov avatar Sep 20 '20 20:09 timahrentlov

@Siedlerchr @Oliyy @timahrentlov Where is the target ssh server hosted? I'm curious is this is specific to AWS.

Cabalist avatar Sep 21 '20 03:09 Cabalist

It's hosted on Digital Ocean.

timahrentlov avatar Sep 21 '20 05:09 timahrentlov

@Cabalist our server is hosted at Hetzner

Siedlerchr avatar Sep 21 '20 07:09 Siedlerchr

@Cabalist This is failing for me too, exactly in this way, on a custom server.

joegatt avatar Sep 21 '20 11:09 joegatt

Failing for me as well: 2020/09/23 07:48:52 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain

muhammad-abdul-raheem avatar Sep 23 '20 08:09 muhammad-abdul-raheem

Failing for me too. Running server on digital ocean. Was working fine a few days ago.

kraj011 avatar Oct 05 '20 03:10 kraj011

I can confirm the error

cafesk8 avatar Oct 15 '20 21:10 cafesk8

Any news about the error? I've been having the same issue too.

angbongon avatar Oct 23 '20 12:10 angbongon

This is failing for me too, haven't had issues before today's attempted deployment.

shealavington avatar Oct 30 '20 17:10 shealavington

I was using this package for a custom CI pipeline on my digital ocean server, but due to this error I had to stop. If anyone else is using DO i recommend using their new app platform which comes with a built in CI pipeline!

kraj011 avatar Oct 30 '20 17:10 kraj011

@kraj011 What new app platform do you use?

appleboy avatar Oct 30 '20 22:10 appleboy

I will create a new video to demo how to use the plugin with the DO server.

appleboy avatar Oct 30 '20 22:10 appleboy

@appleboy It came out very recently; here's a link to it: DO App Platform

kraj011 avatar Oct 31 '20 15:10 kraj011

I've been having the same issue too, someone already solved?

aguinaldotupy avatar Nov 11 '20 21:11 aguinaldotupy

a similar error, I haven't found a solution yet although the authorization key works on the server

UPD re-entered all data in secret and it worked the IP or username may have been entered incorrectly

JoCat avatar Nov 19 '20 16:11 JoCat

Well I was finally able to make it work. I don't remember well what I changed because it was so long ago, but here is my YAML file:

name: CD
on:
  push:
    branches: [main]
jobs:
  deploy:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - name: Repository checkout
        uses: actions/checkout@v2
      - name: Connects to VPS via SSH
        uses: appleboy/[email protected]
        with:
          host: ${{ secrets.SERVER_IP }}
          port: ${{ secrets.SERVER_PORT }}
          username: ${{ secrets.SERVER_USERNAME }}
          key: ${{ secrets.SERVER_KEY }}
          passphrase: ${{ secrets.SERVER_PASSPHRASE }}
          script: |
            cd ${{ secrets.PROJECT_PATH }}
            sudo git checkout main
            sudo git pull origin main
            python3 manage.py migrate
            sudo systemctl restart crm-backend

angbongon avatar Nov 25 '20 19:11 angbongon

I got it! @v0.1.4 work at the moment I guess something is broken in the master branch. So don't use @master.

      - 
        name: Run scripts on servers via SSH
        uses: appleboy/[email protected]
        with:
          host: "${{ secrets.NODE1 }},${{ secrets.NODE2 }},${{ secrets.NODE3 }}"
          #sync: true
          port: ${{ secrets.SSH_PORT }}
          username: ${{ secrets.SSH_USERNAME }}
          key: ${{ secrets.SSH_KEY_ACTIONS }}
          passphrase: ${{ secrets.SSH_KEY_ACTIONS_PASSPHRASE }}
          script: |
            echo && hostname
            cd ${{ secrets.DEPLOY_SETUP_PATH }}
            git rev-parse --short HEAD

pascalandy avatar Dec 31 '20 23:12 pascalandy

v0.1.4 vs master version:

https://github.com/appleboy/ssh-action/compare/v0.1.4...master

I think no difference between v0.1.4 and master.

appleboy avatar Dec 31 '20 23:12 appleboy

LOL that's so weird :-p

pascalandy avatar Jan 01 '21 01:01 pascalandy

i found reason. because ssh_key is incorrect.

cat ~/.ssh/id_rsa don't run at server. use cat ~/.ssh/known_hosts You need to use the matching pub key.

leadscloud avatar Jan 05 '21 07:01 leadscloud

In case it's helpful for anyone else, I dropped down to ssh as a quick hack to unblock myself (in addition to double-checking the authorized_keys on my DigitalOcean droplet):

- name: Deploy
   run: |
     TEMP=$(mktemp)
     echo "${{ secrets.SSH_PRIVATE_KEY }}" > $TEMP
     ssh -o 'StrictHostKeyChecking no' -i $TEMP [email protected] 'bash -s' < scripts/deploy.sh

bcherny avatar Jan 09 '21 03:01 bcherny

That's a good hack :-p

I dropped down to ssh as a quick hack to unblock myself (in addition to double-checking the authorized_keys on my DigitalOcean droplet):

pascalandy avatar Jan 09 '21 16:01 pascalandy