test: Replace hard coded ssh keys on some test

Generate a new ssh key each time. Only implemented on bash test scripts,
go tests pending.
This commit is contained in:
Juan Abia 2021-07-27 15:53:29 +02:00 committed by Alexander Todorov
parent 9c2c92f729
commit c4fa4e4bb7
9 changed files with 63 additions and 24 deletions

27
tools/gen-ssh.sh Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/bash
# Create SSH key
SSH_DATA_DIR="$(mktemp -d)"
SSH_KEY=${SSH_DATA_DIR}/id_rsa
ssh-keygen -f "${SSH_KEY}" -N "" -q -t rsa
# Change cloud-init/user-data ssh key
key=" - $(cat "${SSH_KEY}".pub)"
# Temporary, will copy user data from cloud-init once
# go test are updated
tee "${SSH_DATA_DIR}"/user-data > /dev/null << EOF
#cloud-config
write_files:
- path: "/etc/smoke-test.txt"
content: "c21va2UtdGVzdAo="
encoding: "b64"
owner: "root:root"
permissions: "0644"
user: redhat
ssh_authorized_keys:
${key}
EOF
# Return temp directory
echo "${SSH_DATA_DIR}"