Use SSH key from secret in output (::set-output)


I declare my parameters with this method :

echo '::set-output name=VAR_NAME::VALUES'

If i use directly SSH key from secret that’s works, but I want use from set-outpout

echo '::set-output name=SSH_KEY::${{ secrets.PRODUCTION_SSH_KEY }}'

With this declaration, I have this authentication error :

drone-scp error:  error copy file to dest: ***, error message: ssh: handshake failed: ssh: unable to authenticate, attempted methods [publickey none], no supported methods remain
1 Like


By default, multiline strings is not supported in the value of the output. When you use the multiline strings to set an output, only the string in the first line is recognized as the value of the output.

Due to the SSH private key is multiline strings, so it will be unable to authenticate when you set it as an output.

To solve this problem, you can escape the newline characters (\n, \r) and other special characters (such as ‘%’) in the multiline strings, before setting it as the value of an output.
For example:

      - name: Set output
        id: set-output
        run: |
          multi_line="${{ secrets.MY_SSH_PRIVATE_KEY }}"
          echo "::set-output name=SSH_KEY::$multi_line"

      - name: Checkout
        uses: actions/checkout@v2.3.3
          ssh-key: ${{ steps.set-output.outputs.SSH_KEY }}
1 Like

Thank you very much, I go try this.