Skip to content

Commit

Permalink
πŸ› Init ssh directory before installing keys
Browse files Browse the repository at this point in the history
  • Loading branch information
kierandrewett committed Apr 27, 2024
1 parent fb145a5 commit 86563d2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .github/actions/run-via-ssh/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,25 @@ runs:
tags: ${{ inputs.ts_tags }}

- name: Install SSH key
shell: bash --noprofile --norc -eo pipefail -ux {0}
shell: bash --noprofile --norc -eo pipefail {0}
run: |
mkdir -p ~/.ssh
install -m 600 -D /dev/null ~/.ssh/id_rsa
install -m 600 -D /dev/null ~/.ssh/known_hosts
echo "${{ inputs.ssh_private_key }}" > ~/.ssh/id_rsa
SERVER_IP="$(tailscale ip -6 ${{ inputs.ts_hostname }})"
ping -c 3 $SERVER_IP
ssh-keyscan $SERVER_IP > ~/.ssh/known_hosts
- name: Run script
shell: bash --noprofile --norc -eo pipefail -ux {0}
shell: bash --noprofile --norc -eo pipefail {0}
run: |
SERVER_IP="$(tailscale ip -6 ${{ inputs.ts_hostname }})"
ssh -t ${{ inputs.ssh_username }}@$SERVER_IP "${{ inputs.run }}"
- name: Nuke SSH keys
shell: bash --noprofile --norc -eo pipefail -ux {0}
shell: bash --noprofile --norc -eo pipefail {0}
run: rm -rf ~/.ssh

0 comments on commit 86563d2

Please sign in to comment.