Files
notes/alpine-cloud-init-setup.md.md

121 lines
3.2 KiB
Markdown

########################################
########################################
# install and initial set up
# first boot
boot alpine from network
log in as root
setup-alpine
---------------
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
---------------
apk add nano
---------------
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
---------------
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
---------------
apk update && apk upgrade
apk add util-linux e2fsprogs-extra qemu-guest-agent sudo cfdisk cloud-init
---------------
# enable qemu-guest-agent on boot
---------------
rc-update add qemu-guest-agent
---------------
# add root ssh public keys
---------------
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
---------------
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
---------------
/etc/init.d/sshd restart
---------------
log out and back in with root public key
# configure sudo
---------------
visudo
---------------
remove comment on #%wheel ALL=(ALL:ALL) ALL
remove comment on #%sudo ALL=(ALL:ALL) ALL
---------------
save and exit
# configure cloud-init
---------------
nano /etc/cloud/cloud.cfg
---------------
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
---------------
nano /etc/cloud/cloud.cfg
remove all but NoCloud for datasource_list
---------------
save and exit
# download scripts
---------------
mkdir /root/scripts
wget -qO /root/scripts/download-alpine-scripts.sh aknlw.com/download-alpine-scripts
wget -qO /root/scripts/alpine-resize-disk.sh aknlw.com/alpine-resize-disk
chmod +x /root/scripts/download-alpine-scripts.sh
chmod +x /root/scripts/alpine-resize-disk.sh
---------------
########################################
########################################
# FINALIZE - DO NOT POWER BACK ON BEFORE CONVERTING TO TEMPLATE
---------------
setup-cloud-init
---------------
poweroff
---------------