dont show password rescue password on cmdline and add ability to add authorized_keys file, also let systemd-networkd match on all ethernet devices
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Patrick Michl 2022-02-21 18:57:41 +01:00
parent e427b141c7
commit 05062cabe9
2 changed files with 7 additions and 12 deletions

View File

@ -13,21 +13,21 @@ steps:
environment:
HCLOUD_TOKEN:
from_secret: hcloud_token
SSH_PUBKEY:
from_secret: ssh_pubkey
AUTHORIZED_KEYS_B64:
from_secret: authorized_keys_b64
commands:
- apk add -U openssh
- wget -O- https://github.com/hetznercloud/cli/releases/latest/download/hcloud-linux-amd64.tar.gz | tar zx
- ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -q -N ''
- ./hcloud ssh-key delete drone || true
- ./hcloud ssh-key create --name drone --public-key-from-file /root/.ssh/id_ed25519.pub
- ./hcloud server enable-rescue $SERVER_ID --ssh-key drone
- ./hcloud server enable-rescue $SERVER_ID --ssh-key drone > /dev/null
- ./hcloud server reset $SERVER_ID
- IP="$(./hcloud server ip "$SERVER_ID")"
- until ping -c 1 "$IP"; do sleep 5; done
- until ssh-keyscan "$IP" > /root/.ssh/known_hosts; do sleep 5; done
- scp install-arch.sh root@"$IP":/root/install-arch.sh
- echo "$SSH_PUBKEY" > authorized_keys
- echo "$AUTHORIZED_KEYS_B64" | base64 -d > authorized_keys
- scp authorized_keys root@"$IP":/root/authorized_keys
- ssh root@$IP chmod +x /root/install-arch.sh
- ssh root@$IP /root/install-arch.sh

View File

@ -2,13 +2,9 @@
set -e
set -x
bchroot() {
./root.x86_64/usr/bin/arch-chroot root.x86_64 $@
}
bchroot() { ./root.x86_64/usr/bin/arch-chroot root.x86_64 $@; }
rchroot() {
./root.x86_64/usr/bin/arch-chroot root.x86_64/mnt $@
}
rchroot() { ./root.x86_64/usr/bin/arch-chroot root.x86_64/mnt $@; }
curl -o archlinux-bootstrap.tgz "https://ftp.fau.de/archlinux/iso/latest/archlinux-bootstrap-$(date '+%Y.%m.01')-x86_64.tar.gz"
tar xzf archlinux-bootstrap.tgz
@ -29,8 +25,7 @@ rchroot mkinitcpio -p linux
rchroot grub-install /dev/sda
rchroot grub-mkconfig -o /boot/grub/grub.cfg
IF_NAME="$(udevadm info -q all -p /sys/class/net/eth0 | grep ID_NET_NAME_SLOT | cut -d'=' -f2)"
echo -e "[Match]\nName=${IF_NAME}\n\n[Network]\nDHCP=yes\n" > "root.x86_64/mnt/etc/systemd/network/${IF_NAME}.network"
echo -e "[Match]\nType=ether\n\n[Network]\nDHCP=yes\n" > "root.x86_64/mnt/etc/systemd/network/ether.network"
rchroot systemctl enable systemd-networkd
rchroot systemctl enable systemd-resolved