Suddenly can’t connect without a private SSH key or password in GitHub actions.

huangapple go评论56阅读模式
英文:

Suddenly can't connect without a private SSH key or password in GitHub actions

问题

I am using the continuous deployment by GitHub actions for 1 year or more everything was okay until yesterday when I pushed my updates I found an error in GitHub actions with this message:

> can't connect without a private SSH key or password

This is my yml code

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

      - name: Copy repository contents via scp
        uses: appleboy/scp-action@master
        env:
          HOST: ${{ secrets.HOST }}
          USERNAME: ${{ secrets.USERNAME }}
          PORT: ${{ secrets.PORT }}
          KEY: ${{ secrets.SSHKEY }}
        with:
          source: "."
          target: "/home/ubuntu/dev-folder"

      - name: Executing remote command
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST }}
          USERNAME: ${{ secrets.USERNAME }}
          PORT: ${{ secrets.PORT }}
          KEY: ${{ secrets.SSHKEY }}
          command_timeout: 10m
          script: cd dev-folder;
            mvn package install

I didn't change anything in the yml file

Did GitHub change anything on its policy?

I searched and I didn't find anything to solve my problem

英文:

I am using the continuous deployment by GitHub actions for 1 year or more everything was okay until yesterday when I pushed my updates I found an error in GitHub actions with this message:

> can't connect without a private SSH key or password

This is my yml code

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

      - name: Copy repository contents via scp
        uses: appleboy/scp-action@master
        env:
          HOST: ${{ secrets.HOST }}
          USERNAME: ${{ secrets.USERNAME }}
          PORT: ${{ secrets.PORT }}
          KEY: ${{ secrets.SSHKEY }}
        with:
          source: "."
          target: "/home/ubuntu/dev-folder"

      - name: Executing remote command
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST }}
          USERNAME: ${{ secrets.USERNAME }}
          PORT: ${{ secrets.PORT }}
          KEY: ${{ secrets.SSHKEY }}
          command_timeout: 10m
          script: cd dev-folder;
            mvn package install

I didn't change anything in the yml file

Did GitHub change anything on its policy?

I searched and I didn't find anything to solve my problem

答案1

得分: 5

Change

env:
  host: ${{ secrets.SSH_HOST }}
  username: ${{ secrets.SSH_USER }}
  key: ${{ secrets.SSH_KEY }}
  port: ${{ secrets.SSH_PORT}}
with:
  source: ''.'
  target: ${{ secrets.PATH }}

to

with:
  host: ${{ secrets.SSH_HOST }}
  username: ${{ secrets.SSH_USER }}
  key: ${{ secrets.SSH_KEY }}
  port: ${{ secrets.SSH_PORT}}
  source: ''.'
  target: ${{ secrets.PATH }}
英文:

I finally found the solution here: https://github.com/appleboy/scp-action/issues/113

Change

env:
  host: ${{ secrets.SSH_HOST }}
  username: ${{ secrets.SSH_USER }}
  key: ${{ secrets.SSH_KEY }}
  port: ${{ secrets.SSH_PORT}}
with:
  source: '.'
  target: ${{ secrets.PATH }}

to

with:
  host: ${{ secrets.SSH_HOST }}
  username: ${{ secrets.SSH_USER }}
  key: ${{ secrets.SSH_KEY }}
  port: ${{ secrets.SSH_PORT}}
  source: '.'
  target: ${{ secrets.PATH }}

答案2

得分: 1

我不熟悉那两个苹果男孩的操作,但快速查看项目后,他们最近发布了一个基础的Docker镜像,改变了环境变量的使用方式:

https://github.com/appleboy/drone-ssh/pull/252

在需要时修改EnvVars切片以包含INPUT_前缀

...

此外,您正在使用一个非常旧的/过时的actions/checkout@v1版本。

我强烈建议更新您的配置以处理最新版本。

英文:

I'm not familiar with those two appleboy actions but taking a quick look at the projects, there was a recent release of their base docker image that changes how env vars are getting used:

https://github.com/appleboy/drone-ssh/pull/252

> Modify the EnvVars slice to include INPUT_ prefix when needed
>
> ...

Additionally, you're using a very old / outdated version of the actions/checkout@v1

I'd strongly recommend updating your config to handle the latest versions.

huangapple
  • 本文由 发表于 2023年4月17日 02:18:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76029565.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定