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

ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain #297

Open
sahgilbert opened this issue Feb 10, 2024 · 12 comments

Comments

@sahgilbert
Copy link

sahgilbert commented Feb 10, 2024

I have an Asp.Net Core (.Net 8.0) app, straight out of the box from Visual Studio for Mac.

I'm using a MacBook Pro (Silicon chip).

I have generated an SSH RSA key pair on my local mac machine.

I have created an Azure Virtual Machine running Linux.

When I created the Virtual Machine in the Azure Portal, I uploaded my public key which was generated by my previous step.

I have added the 3 required secrets to the source code repository on GitHub, based on the secrets variables in the deploy.yml file, as per the below screenshot:

Screenshot 2024-02-10 at 18 44 03

I'm getting the following error when trying to deploy Asp.Net Core to an Azure Virtual Machine using GitHub Actions & appleboy/ssh-action:

ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

Screenshot 2024-02-10 at 20 23 25

I have created a deploy.yml file for the deployment via GitHub Actions, with the following contents

`name: Deploy to Azure VM

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

  steps:
    - name: Checkout Repository
      uses: actions/checkout@v2

    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '8.x'

    - name: Build and Publish
      run: dotnet publish -c Release -o publish

    - name: Deploy to Azure VM
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.AZURE_VM_HOST }} # Azure VM IP address or hostname
        username: ${{ secrets.AZURE_VM_USERNAME }}
        key: ${{ secrets.AZURE_VM_SSH_PRIVATE_KEY }}
        script: |
          whoami
          cd /home/runner/work/
          git pull origin main
          sudo systemctl restart nameofmyvirtualmachineinmicrosoftazuregoeshere

`
How do I debug this error? Are there some debug settings that I can add to my deploy.yml file?

Thanks

@Sven65
Copy link

Sven65 commented Feb 12, 2024

Also experiencing this issue. I've set the debug input to true, yet it appears that no debug information is output.

@LucasRoquilly
Copy link

I have exact same problem. I followed every instruction in documentation but still same error :
ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

However it works using this Github Action :
https://github.com/marketplace/actions/copy-via-ssh

@sahgilbert
Copy link
Author

I have exact same problem. I followed every instruction in documentation but still same error : ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

However it works using this Github Action : https://github.com/marketplace/actions/copy-via-ssh

Do you have a full working example of a workflow.yml file, for this implementation, that you could share? That would be greatly appreciated, thank you.

@real-F-00
Copy link

real-F-00 commented Feb 17, 2024

i'm getting the same thing here, after days of going crazy i couldn't figure out what i did wrong, and apparently i'm not the only one facing this issue, i should mention that i'm running a hardened SSH server on Debian 12 using the configuration provided by ssh-audit.com simply trying to follow this guide i found on Youtube and using a separate user as opposed to the root user.

@appleboy
Copy link
Owner

@real-F-00 Have you solved the problem?

@LucasRoquilly
Copy link

LucasRoquilly commented Feb 20, 2024

I fixed my problem and ssh-action is now working. I feel stupid, I was using SSH_USERNAME in my yml file but the secret was called SSH_USER in GitHub Secrets 😑

Here is my working yml file for anyone it might help :

name: Deploy to VPS

on:
  push:
    branches:
      - main  # Adjust this to your main branch name
  workflow_dispatch: 
  
jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Copy files to VPS
      uses: appleboy/scp-action@master
      with:
        host: ${{ secrets.SSH_HOST }}
        username: ${{ secrets.SSH_USER }}
        key: ${{ secrets.SSH_PRIVATE_KEY }}
        port: ${{ secrets.SSH_PORT }}  # If your SSH server uses a different port, add this line
        source: "public_html"  # Adjust this to the directory or files you want to copy
        target: "/var/www/domain.com/"  # Adjust this to the destination directory on your VPS
    - name: multiple command
      uses: appleboy/ssh-action@v1.0.3
      with:
        host: ${{ secrets.SSH_HOST }}
        username: ${{ secrets.SSH_USER }}
        key: ${{ secrets.SSH_PRIVATE_KEY }}
        port: ${{ secrets.SSH_PORT }}
        script: |
          chown -R openvc:www-data /var/www/domain.com/public_html
          chmod -R 770 /var/www/domain.com/public_html`

@sahgilbert
Copy link
Author

I fixed my problem and ssh-action is now working. I feel stupid, I was using SSH_USERNAME in my yml file but the secret was called SSH_USER in GitHub Secrets 😑

Here is my working yml file for anyone it might help :

name: Deploy to VPS

on:
  push:
    branches:
      - main  # Adjust this to your main branch name
  workflow_dispatch: 
  
jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Copy files to VPS
      uses: appleboy/scp-action@master
      with:
        host: ${{ secrets.SSH_HOST }}
        username: ${{ secrets.SSH_USER }}
        key: ${{ secrets.SSH_PRIVATE_KEY }}
        port: ${{ secrets.SSH_PORT }}  # If your SSH server uses a different port, add this line
        source: "public_html"  # Adjust this to the directory or files you want to copy
        target: "/var/www/domain.com/"  # Adjust this to the destination directory on your VPS
    - name: multiple command
      uses: appleboy/ssh-action@v1.0.3
      with:
        host: ${{ secrets.SSH_HOST }}
        username: ${{ secrets.SSH_USER }}
        key: ${{ secrets.SSH_PRIVATE_KEY }}
        port: ${{ secrets.SSH_PORT }}
        script: |
          chown -R openvc:www-data /var/www/domain.com/public_html
          chmod -R 770 /var/www/domain.com/public_html`

Does this deploy to Microsoft Azure? Or are you using a different Cloud Provider? Thanks

@real-F-00
Copy link

@real-F-00 Have you solved the problem?

Yes! after days of headaches i finally solved the issue, i think this should be added to the documentation (if it isn't already) but the problem was that the user i was trying to use was locked, to keep the user locked but allowing ssh access to it i used usermod -p '*' user that solved my issue.

@LucasRoquilly
Copy link

Does this deploy to Microsoft Azure? Or are you using a different Cloud Provider? Thanks

@sahgilbert This was made for deployment to a OVHCloud VPS (Virtual Private Server) but I believe it should work for any Linux machine

@appleboy
Copy link
Owner

@LucasRoquilly Can you provide the ssh username and password through email (appleboy.tw AT gmail.com). Maybe I can try it and get you back soon?

Thanks.

@appleboy
Copy link
Owner

@LucasRoquilly

I will try out OVHCloud and promptly inform you if the product becomes available.

image

@appleboy
Copy link
Owner

Sorry, I misunderstood @LucasRoquilly. The issue lies with @sahgilbert problem on Azure. I will find time to test the issue on Azure again.

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

No branches or pull requests

5 participants