docs: update alpine/alpine-cloud-init-setup

This commit is contained in:
2024-04-17 03:36:21 +00:00
parent 8cc42c7a11
commit 72cba0e8d4
+51 -44
View File
@@ -1,10 +1,20 @@
---
title: alpine-cloud-init-setup
description:
published: true
date: 2024-04-17T03:36:19.631Z
tags:
editor: markdown
dateCreated: 2024-04-15T20:41:58.346Z
---
# 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
@@ -26,94 +36,91 @@ ssh key for root: default
format: /dev/sda
filesystem: sys
write disk: y
---------------
reboot
########################################
########################################
# CONFIGURATION
# set nano as default editor
---------------
## 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
---------------
## 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
---------------
## 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
---------------
## enable qemu-guest-agent on boot
```bin
rc-update add qemu-guest-agent
---------------
```
# add root ssh public keys
---------------
## 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
---------------
## 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
---------------
## 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
---------------
nano /etc/cloud/cloud.cfg
---------------
## 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
---------------
## download scripts
```bin
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
---------------
## FINALIZE - DO NOT POWER BACK ON BEFORE CONVERTING TO TEMPLATE
```bin
setup-cloud-init
---------------
```
```bin
poweroff
---------------
```