diff --git a/cuddle.yaml b/cuddle.yaml index 5f7db62..8d7882c 100644 --- a/cuddle.yaml +++ b/cuddle.yaml @@ -16,3 +16,5 @@ scripts: type: shell deploy_release: type: shell + setup_ssh: + type: shell diff --git a/scripts/setup_ssh.sh b/scripts/setup_ssh.sh new file mode 100755 index 0000000..5d92c88 --- /dev/null +++ b/scripts/setup_ssh.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e + +if [ ! -d ~/.ssh ]; then + mkdir -p ~/.ssh + chmod 700 ~/.ssh +fi + +if [ -n "$SSH_KEY" ]; then + SSH_KEY_ID="$HOME/.ssh/id_ed25519" + echo $SSH_KEY > $SSH_KEY_ID + + chmod 600 $SSH_KEY_ID + + # Append the required to the ssh config file. + # Switch out the hostname for different hosts. + # The line count is 5 + echo "\nHost ci.i.kjuulh.io\n"\ + " IdentityFile ${SSH_KEY_ID}\n"\ + " IdentitiesOnly yes\n"\ + " UserKnownHostsFile=/dev/null\n"\ + " StrictHostKeyChecking no"\ + >> $HOME/.ssh/config +fi