packer: update build scripts, install SSH keys

This commit is contained in:
2023-04-12 20:16:58 -07:00
parent 46b17d2f05
commit 906d1ae5ac
5 changed files with 64 additions and 10 deletions

26
packer/scripts/setup-ssh.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -euxo pipefail
source /etc/os-release
case "${ID}" in
ubuntu)
SYSTEM_USER=ubuntu
SYSTEM_HOME=/home/${SYSTEM_USER}
;;
*)
SYSTEM_USER=root
SYSTEM_HOME=/root
;;
echo "[+] setting up ssh"
apt-get -y install openssh-server
SSH_DIR="${SYSTEM_HOME}/.ssh"
mkdir -p ${SYSTEM_HOME}/.ssh
chmod 0700 ${SSH_DIR}
mv /tmp/authorized_keys ${SSH_DIR}/authorized_keys
chmod 0644 ${SSH_DIR}/authorized_keys