【问题标题】:appleboy/ssh-action No such device or address errorappleboy/ssh-action 没有这样的设备或地址错误
【发布时间】:2021-11-14 12:51:29
【问题描述】:

我正在尝试为 laravel 项目创建一个自动部署文件。

这是我的 yml 文件代码。 工作: 部署:

runs-on: ubuntu-latest

steps:
- name: Checkout
  uses: actions/checkout@v2 
- name: Deployment
  uses: appleboy/ssh-action@master
 
  with:
    host: ${{ secrets.SSH_HOST }}
    key: ${{ secrets.SSH_PRIVATE_KEY }}
    username: ${{ secrets.SSH_USERNAME }}
    script: |
      cd path-to-my-directory

      git pull
      php artisan migrate

git pull 返回could not read Username for 'https://github.com': No such device or address 错误。但我确信username, key, host 设置正确。 无法解决问题或找到类似问题的解决方案

【问题讨论】:

    标签: laravel ssh devops github-actions


    【解决方案1】:

    如果您设置了 SSH 密钥,而您的 URL 是 HTTPS 的,则不会使用该密钥。完全没有。

    相反,Git 在 GitHub Action 中会尝试通过 HTTPS 获取私有存储库的凭据(用户名/密码)。

    另外,SSH URL 无论如何都会使用用户名git,以及允许远程服务器对实际用户进行身份验证的私有 SSH 密钥。

    您可以see here an example 的 GitHub Action 实际使用 SSH URL:

    on: [push]
    
    jobs:
      try-ssh-commands:
        runs-on: ubuntu-latest
        name: SSH MY_TEST
        steps:
          - name: Checkout
            uses: actions/checkout@v2
          - name: test_ssh
            uses: ./
            with:
              ssh_key: ${{secrets.SSH_PRIVATE_KEY}}
              known_hosts: ${{secrets.SSH_KNOWN_HOSTS}}
    

    但是,如果您使用的是 HTTPS,并且如 cmets 中所述,请使用 OP:

    • 您需要一个 PAT(个人访问令牌)
    • 你需要存储它:git config credential.helper store + git pull

    【讨论】:

    • 我注意到 Github 实际上没有使用用户名密码对。如果我想手动拉,我必须使用个人访问令牌。但是我通过手动运行git config credential.helper storegit pull 解决了这个问题。之后工作流按预期运行
    • @TakhtakTeam 太好了,干得好。我已将您的评论包含在答案中以提高知名度。
    猜你喜欢
    • 2020-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-25
    • 1970-01-01
    • 2020-08-16
    相关资源
    最近更新 更多