github-action-ssh
github-action-ssh copied to clipboard
Pass secrets to SSH command
How can I pass secrets to the SSH command? Running the following command doesn't output MY_SECRET as an environment variable.
Thanks
- name: Start container services
uses: garygrossgarten/github-action-ssh@release
env:
MY_SECRET: ${{ secrets.MY_SECRET }}
with:
host: ${{ steps.tf_out.outputs.vm_ip }}
username: terraform
privateKey: ${{ secrets.TF_KEY }}
command: |
printenv
The action environment is not exported to the ssh host. There would be grave security concerns. You can pass them yourself with something like this, because ${{}} is evaluated before passing the string to the ssh action. But be careful, this could makes the secret a part of the ssh history or visible through ps.
- name: Start container services
uses: garygrossgarten/github-action-ssh@release
with:
host: ${{ steps.tf_out.outputs.vm_ip }}
username: terraform
privateKey: ${{ secrets.TF_KEY }}
command: |
MY_SECRET: ${{ secrets.MY_SECRET }}
printenv