From f6e1ee3af93f16d33f025bd9fbfafcc0cb14c3b0 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Thu, 13 Apr 2023 09:55:54 -0700 Subject: [PATCH] packer: move authorized_keys setup to cloud-init. --- packer/files/authorized_keys | 5 ---- packer/files/user-data | 51 ++++++++++++++++++++++++++++++++++++ packer/scripts/setup-ssh.sh | 10 +------ 3 files changed, 52 insertions(+), 14 deletions(-) delete mode 100644 packer/files/authorized_keys create mode 100644 packer/files/user-data diff --git a/packer/files/authorized_keys b/packer/files/authorized_keys deleted file mode 100644 index eff8661..0000000 --- a/packer/files/authorized_keys +++ /dev/null @@ -1,5 +0,0 @@ -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM47gCbb0BQOm6H4Ol8DEKD+CXTNYDJxe7QvJhdLZR/F kyle@petrichor -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGea83yMIdCi0QUUPgmhRgIrii7lS1dYxZ6LSxSsDOph kyle@europa -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEbkHs8zGZ3L6tRILjX7Cph8kXSpuw665mxe4ak2dwIx kyle@hermes -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICOCXJx+3ynRraM0JIsUy6Cin9JByPW/EUV9ggtuUCbC kyle@freeside -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINfRxWmx30LhGnsXpauLrj3GPvBWLhAKs0EznA9cNT5q kyle@deimos diff --git a/packer/files/user-data b/packer/files/user-data new file mode 100644 index 0000000..152e7b4 --- /dev/null +++ b/packer/files/user-data @@ -0,0 +1,51 @@ +#cloud-config + +# This is the user-data configuration file for cloud-init. By default this sets +# up an initial user called "ubuntu" with password "ubuntu", which must be +# changed at first login. However, many additional actions can be initiated on +# first boot from this file. The cloud-init documentation has more details: +# +# https://cloudinit.readthedocs.io/ +chpasswd: + expire: false + list: + - ubuntu:ubuntu + +hostname: rp3b-cdev +ssh_pwauth: true +ssh_authorized_keys: + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM47gCbb0BQOm6H4Ol8DEKD+CXTNYDJxe7QvJhdLZR/F kyle@petrichor + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGea83yMIdCi0QUUPgmhRgIrii7lS1dYxZ6LSxSsDOph kyle@europa + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEbkHs8zGZ3L6tRILjX7Cph8kXSpuw665mxe4ak2dwIx kyle@hermes + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICOCXJx+3ynRraM0JIsUy6Cin9JByPW/EUV9ggtuUCbC kyle@freeside + - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINfRxWmx30LhGnsXpauLrj3GPvBWLhAKs0EznA9cNT5q kyle@deimos +ssh_deletekeys: true +ssh_genkeytypes: [rsa, ecdsa, ed25519] +disable_root: true + +resize_rootfs: true + +## Update apt database and upgrade packages on first boot +#package_update: true +#package_upgrade: true + +## Install additional packages on first boot +#packages: +#- avahi-daemon +#- rng-tools +#- python3-gpiozero +#- [python3-serial, 3.5-1] + +## Run arbitrary commands at rc.local like time +#runcmd: +#- [ ls, -l, / ] +#- [ sh, -xc, "echo $(date) ': hello world!'" ] +#- [ wget, "http://ubuntu.com", -O, /run/mydir/index.html ] + +network: + Version: 2 + Renderer: networkd + ethernets: + eth0: + dhcp4: yes + diff --git a/packer/scripts/setup-ssh.sh b/packer/scripts/setup-ssh.sh index 5b81c2e..acaffaa 100755 --- a/packer/scripts/setup-ssh.sh +++ b/packer/scripts/setup-ssh.sh @@ -13,14 +13,6 @@ case "${ID}" in SYSTEM_USER=root SYSTEM_HOME=/root ;; +esac -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 -