From 86563d202c2b53d37159740460e5b88dabed6f19 Mon Sep 17 00:00:00 2001 From: kierandrewett Date: Sat, 27 Apr 2024 21:08:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Init=20ssh=20directory=20before?= =?UTF-8?q?=20installing=20keys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/run-via-ssh/action.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/actions/run-via-ssh/action.yml b/.github/actions/run-via-ssh/action.yml index c9ed87b..b14065c 100644 --- a/.github/actions/run-via-ssh/action.yml +++ b/.github/actions/run-via-ssh/action.yml @@ -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