【问题标题】:GitHub Action: Accessing a Server from GitHub via SSHGitHub 操作:通过 SSH 从 GitHub 访问服务器
【发布时间】:2021-12-20 08:09:41
【问题描述】:

我有一个可以连接到我的服务器的 shell 脚本。它在那里执行一些 shell 命令。现在我想将脚本集成到我的 GitHub 操作工作流程中。我已将脚本放在我的存储库中,并且脚本也已启动。但是我还没有任何 ssh 命令,只有脚本中的 echo 命令。因此它运行成功。

现在我想将 SSH 命令添加到脚本中。但我想知道我现在应该如何处理 SSH 密钥。据我了解,GitHub 没有私钥,我可以从中生成我的公钥,然后将其存储在服务器上。

【问题讨论】:

    标签: github ssh deployment continuous-integration github-actions


    【解决方案1】:

    您可以考虑使用 GitHub Action appleboy/ssh-action

    执行远程 ssh 命令。

    name: remote ssh command
    on: [push]
    jobs:
    
      build:
        name: Build
        runs-on: ubuntu-latest
        steps:
        - name: executing remote ssh commands using password
          uses: appleboy/ssh-action@master
          with:
            host: ${{ secrets.HOST }}
            username: ${{ secrets.USERNAME }}
            password: ${{ secrets.PASSWORD }}
            port: ${{ secrets.PORT }}
            script: whoami
    

    您可以将您的私钥和其他敏感数据注册为GitHub secret for your repository

    【讨论】:

      猜你喜欢
      • 2021-03-09
      • 1970-01-01
      • 2014-02-19
      • 1970-01-01
      • 2020-03-06
      • 1970-01-01
      • 1970-01-01
      • 2021-08-16
      • 2012-04-27
      相关资源
      最近更新 更多