# alpine_cloud_init_setup ## **INSTALL AND INITIAL SETUP** ## first boot boot alpine from network log in as root ## setup-alpine ```bash keyboard: us keyboard locale: us-intl hostname: default network interface: default dhcp: default netmask: default gateway: default manual network changes: default network suffix: lan dns: default set root password timezone: America/Chicago proxy: default mirror: default add user: default ssh server: default allow ssh root login: yes ssh key for root: default format: /dev/sda filesystem: sys write disk: y reboot ``` ## **CONFIGURATION** ## set nano as default editor ```bin apk add nano ``` ```bin echo "EDITOR=nano" > /etc/profile.d/default_editor.sh echo "export EDITOR" >> /etc/profile.d/default_editor.sh ``` save and exit log out and back in ## update repos ```bin echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/main" > /etc/apk/repositories echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories ``` ## update and install packages ```bin apk update && apk upgrade apk add util-linux e2fsprogs-extra qemu-guest-agent sudo cfdisk cloud-init ``` ## enable qemu-guest-agent on boot ```bin rc-update add qemu-guest-agent ``` ## add root ssh public keys ```bin mkdir /root/.ssh echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHWiw5lVzQIZiZc1SPphvHhdSpFl9UN6Xm4znFqq5xs4 server-root" > /root/.ssh/authorized_keys echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBI/kuy/SVCxShVBNtWtNREX9cpWrlsthV3z15ky+bPy winpc-root" >> /root/.ssh/authorized_keys chmod 600 /root/.ssh/* ``` ## change sshd config back to default ```bin sed -i 's/PermitRootLogin yes/#PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config ``` save and exit restart sshd ```bin /etc/init.d/sshd restart ``` log out and back in with root public key ## configure sudo ```bin visudo ``` remove comment on #%wheel ALL=(ALL:ALL) ALL remove comment on #%sudo ALL=(ALL:ALL) ALL save and exit ## configure cloud-init ```bin sed -i 's/disable_root: true/disable_root: false/g' /etc/cloud/cloud.cfg sed -i 's/groups: [adm, wheel]/groups: [adm, wheel, sudo]/g' /etc/cloud/cloud.cfg ``` ```bin nano /etc/cloud/cloud.cfg ``` remove all but NoCloud for datasource_list save and exit ## download scripts ```bin mkdir /root/scripts wget -qO /root/scripts/download-alpine-scripts.sh aknlw.com/download-alpine-scripts chmod +x /root/scripts/download-alpine-scripts.sh ``` ## **FINALIZE - DO NOT POWER BACK ON BEFORE CONVERTING TO TEMPLATE** ```bin setup-cloud-init ``` ```bin poweroff ```