diff --git a/init.sh b/init.sh new file mode 100755 index 0000000000000000000000000000000000000000..72e7851dd6b7961164231904615fd4f947a063d0 --- /dev/null +++ b/init.sh @@ -0,0 +1,26 @@ +generateKey() { + touch sshKey + touch sshKey.pub + rm sshKey + rm sshKey.pub + ssh-keygen -t ed25519 -f ./sshKey -q -N "" -C "" +} + +deployKey() { + sshpass -p alarm ssh-copy-id -i ./sshKey.pub -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PubkeyAuthentication=false alarm@$1 +} + +# If keys are present, we just need to deploy it and destroy the SSH Agent +# Otherwise, we genrate a key and then deploy it +# The key can be present on the remote host multiple times, +# -> not a big issue, just not clean, but it works +[ -e sshKey ] && [ -e sshKey.pub ] || generateKey + + +for remoteHost in "$@" +do + echo "$remoteHost" + deployKey "$remoteHost" +done + +export SSH_AUTH_SOCK=/dev/null