Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用GitHub操作发送ssh add的密码短语?_Ssh_Github Actions - Fatal编程技术网

如何使用GitHub操作发送ssh add的密码短语?

如何使用GitHub操作发送ssh add的密码短语?,ssh,github-actions,Ssh,Github Actions,我的目标是将带有密码短语的私钥存储在GitHub secrets中,但我不知道如何通过GitHub操作输入密码短语 我所尝试的: 我创建了一个没有密码短语的私钥,并将其存储在GitHub secrets中 .github/workflows/docker-build.yml # This is a basic workflow to help you get started with Actions name: CI # Controls when the action will run.

我的目标是将带有密码短语的私钥存储在GitHub secrets中,但我不知道如何通过GitHub操作输入密码短语

我所尝试的:

  • 我创建了一个没有密码短语的私钥,并将其存储在GitHub secrets中
  • .github/workflows/docker-build.yml

    # This is a basic workflow to help you get started with Actions
    
    name: CI
    
    # Controls when the action will run. 
    on:
      # Triggers the workflow on push or pull request events but only for the master branch
      push:
        branches: [ master ]
    
      # Allows you to run this workflow manually from the Actions tab
      workflow_dispatch:
    
    # A workflow run is made up of one or more jobs that can run sequentially or in parallel
    jobs:
      # This workflow contains a single job called "build"
      build:
        # The type of runner that the job will run on
        runs-on: ubuntu-latest
    
        # Steps represent a sequence of tasks that will be executed as part of the job
        steps:
          # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
          - uses: actions/checkout@v2
    
          # Runs a set of commands using the runners shell
          - name: Run a multi-line script
            run: |
              eval $(ssh-agent -s)
              echo "${{ secrets.SSH_PRIVATE_KEY }}" |  ssh-add -
              ssh -o StrictHostKeyChecking=no root@${{ secrets.HOSTNAME }} "rm -rf be-bankaccount; git clone https://github.com/kidfrom/be-bankaccount.git; cd be-bankaccount; docker build -t be-bankaccount .; docker-compose up -d;"
    
    您可以尝试使用,它来自于“”中所做的研究

    GitHub操作只能访问其运行的存储库。因此,为了访问其他私有存储库,请创建具有足够访问权限的SSH密钥。
    然后,使用此操作使该密钥可用于操作工作节点上的ssh代理。一旦设置好了,使用ssh URL的git clone命令就可以正常工作了

    #.github/workflows/my-workflow.yml
    工作:
    我的工作:
    ...
    步骤:
    -行动/checkout@v1
    #确保@v0.4.1与当前版本的
    #行动
    -用法:webfactory/ssh-agent@v0.4.1
    与:
    ssh私钥:${secrets.ssh_private_key}
    - ... 其他步骤
    
    您可以尝试使用,它来自于在“”中完成的研究

    GitHub操作只能访问其运行的存储库。因此,为了访问其他私有存储库,请创建具有足够访问权限的SSH密钥。
    然后,使用此操作使该密钥可用于操作工作节点上的ssh代理。一旦设置好了,使用ssh URL的git clone命令就可以正常工作了

    #.github/workflows/my-workflow.yml
    工作:
    我的工作:
    ...
    步骤:
    -行动/checkout@v1
    #确保@v0.4.1与当前版本的
    #行动
    -用法:webfactory/ssh-agent@v0.4.1
    与:
    ssh私钥:${secrets.ssh_private_key}
    - ... 其他步骤
    
    为什么不为CI创建一个没有密码的版本?@jornsharpe目前我使用一个没有密码的版本。我不想在将来这样做。我知道这毫无意义,但这会让我的心放松一点。如果你知道这毫无意义,那为什么“放松你的心”?它不再安全了,因为如果攻击者能够访问这些机密,他们将同时拥有这两部分。为什么不创建一个没有密码的CI呢?@jornsharpe目前我使用一个没有密码的。我不想在将来这样做。我知道这毫无意义,但这会让我的心放松一点。如果你知道这毫无意义,那为什么“放松你的心”?它不再安全了,因为如果攻击者能够访问这些秘密,他们无论如何都会同时拥有这两部分。