无法通过 Github 操作连接到 SSH

问题描述 投票:0回答:1

我使用以下 yml 文件通过

SSH
部署我的网站代码,但遇到以下错误:

on:
  push:
    branches:
      - main
  workflow_dispatch:
jobs:

  build:
    name: Build Website
    runs-on: ubuntu-latest

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

      - name: Install Dependencies
        run: yarn install --frozen-lockfile
      - name: Build SSR
        run: npx quasar build -m ssr

      - name: Upload Build Artifacts
        uses: actions/upload-artifact@v2
        with:
          name: build-artifacts
          path: './dist/ssr'

  deploy:
    name: Deploy to Production
    runs-on: ubuntu-latest
    needs: [build]
   
    steps:
      - name: Install SSH Key
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.SSH_KEY }}
          known_hosts: 'just-a-placeholder-so-we-dont-get-errors'

      - name: Adding Known Hosts
        run: ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts

      - name: Deploy with rsync
        # run: rsync -avz -e "ssh -p ${{ secrets.SSH_PORT }}" ./dist/ssr ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ vars.HOST_PATH }}
        run: rsync -avz -e "ssh -oHostKeyAlgorithms=+ssh-rsa -p ${{ secrets.SSH_PORT }}" ./dist/ssr/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ vars.HOST_PATH }}

错误:

##[debug]Evaluating condition for step: 'Deploy with rsync'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Deploy with rsync
##[debug]Loading inputs
##[debug]Evaluating: format('rsync -avz -e "ssh -oHostKeyAlgorithms=+ssh-rsa -p {0}" ./dist/ssr/ {1}@{2}:{3}', secrets.SSH_PORT, secrets.SSH_USER, secrets.SSH_HOST, vars.HOST_PATH)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> 'rsync -avz -e "ssh -oHostKeyAlgorithms=+ssh-rsa -p {0}" ./dist/ssr/ {1}@{2}:{3}'
##[debug]..Evaluating Index:
##[debug]....Evaluating secrets:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'SSH_PORT'
##[debug]..=> '***'
##[debug]..Evaluating Index:
##[debug]....Evaluating secrets:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'SSH_USER'
##[debug]..=> '***'
##[debug]..Evaluating Index:
##[debug]....Evaluating secrets:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'SSH_HOST'
##[debug]..=> '***'
##[debug]..Evaluating Index:
##[debug]....Evaluating vars:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'HOST_PATH'
##[debug]..=> '/home/***/ssr/'
##[debug]=> 'rsync -avz -e "ssh -oHostKeyAlgorithms=+ssh-rsa -p ***" ./dist/ssr/ ***@***:/home/***/ssr/'
##[debug]Result: 'rsync -avz -e "ssh -oHostKeyAlgorithms=+ssh-rsa -p ***" ./dist/ssr/ ***@***:/home/***/ssr/'
##[debug]Loading env
Run rsync -avz -e "ssh -oHostKeyAlgorithms=+ssh-rsa -p ***" ./dist/ssr/ ***@***:/home/***/ssr/
##[debug]/usr/bin/bash -e /home/runner/work/_temp/34c64e52-8d53-407f-9c49-c1e6fd415600.sh
sign_and_send_pubkey: no mutual signature supported
Permission denied, please try again.
Permission denied, please try again.
***@***: Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7]
Error: Process completed with exit code 12.
##[debug]Finishing: Deploy with rsync

仅供参考,我可以使用其他机器通过 ssh 连接!

我希望连接没有问题!

ssh continuous-integration github-actions
1个回答
0
投票

我也有同样的问题。你是如何复制你的 ssh 密钥的?我想你做了类似

$ car <your private ssh>
的事情,然后复制了结果并粘贴了它,对吧?那是我的错误。以这种方式操作,您将在 ssh 密钥中拥有多余的线路制动。我的解决方案是使用 Windows 工具来复制密钥。我的意思不是vi,不是vim,不是nano,而是notepad++。我使用 WSL2 生成了密钥对。然后我使用 Windows 文件浏览器和 notepad++ 打开密钥。之后,rsync步骤开始工作。

© www.soinside.com 2019 - 2024. All rights reserved.