Score:0

Is it safe to deploy without ssh-agent on GitHub Actions?

cn flag

I see 2 options here, using ssh-agent:

name: deploy
on: [push]
jobs:
  deploy:
    runs-on: ubuntu-20.04
    env:
      USER_HOST: ec2-user@ec2...
      HOST_KEY: ec2... ecdsa-sha2-nistp256 AAAA...mXU=
    steps:
      - name: Check out the code
        uses: actions/checkout@v2

      - name: Run ssh-agent
        uses: webfactory/[email protected]
        with:
          ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

      - name: Add the host key to ~/.ssh/known_hosts
        run: |
          echo "$HOST_KEY" >> ~/.ssh/known_hosts

      - name: Deploy
        run: |
          set -x
          BRANCH=${GITHUB_REF#refs/heads/}
          cat .github/deploy.sh | ssh -T "$USER_HOST" sh -s "$BRANCH"

And w/o ssh-agent:

name: deploy
on: [push]
jobs:
  deploy:
    runs-on: ubuntu-20.04
    env:
      USER_HOST: ec2-user@ec2...
      HOST_KEY: ec2... ecdsa-sha2-nistp256 AAAA...mXU=
    steps:
      - name: Check out the code
        uses: actions/checkout@v2

      - name: Set up ssh
        run: |
          set -x
          mkdir ~/.ssh
          echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
          chmod 0600 ~/.ssh/id_rsa
          echo "$HOST_KEY" >> ~/.ssh/known_hosts
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}

      - name: Deploy
        run: |
          set -x
          BRANCH=${GITHUB_REF#refs/heads/}
          cat .github/deploy.sh | ssh -Ti ~/.ssh/id_rsa "$USER_HOST" sh -s "$BRANCH"

Are both of them safe? Or should one of them be preferred? webfactory/ssh-agent doesn't store the key on disk.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.