How to Setup Alpine Linux on Kernel-Based Virtual Machine
November 11, 2022
Install Alpine
The I’ve been a happy customer of RAMHost for over eight years. It’s a great deal and the support is excellent. kernel-based virtual machine (KVM) I’m using here is a TinyKVM from RAMHost, which you can get for $15/year. It takes about five minutes to set one up.
- Login to your TinyKVM account.
- Note down the IP address, netmask and gateway.
- Pick “OS Manual Reload” icon.
- Select “alpine-extended-3.16.0-x86_64.iso” and click the Reload button.
- Wait a couple minutes.
- Click “Back to Main”.
- Click the “VNC Console” icon.
- Click “>> Launch NoVNC Client (recommended) <<”.
- Maximize the browser.
- You should see the Alpine Linux login prompt.
Setup Alpine
If you make a mistake, just press Ctrl-C and then restart setup-alpine.
- Login as root.
- Type setup-alpine at prompt and hit Enter.
- Enter the static IP / Gateway / Net Mask that you noted down above.
- 8.8.8.8 (Google) for DNS server
- Enter “sda” for hard disk to use. I missed entering “sda” the first four times through the installer. ☹️
- “sys” for how you would like to use the disk.
- “y” erase disk and set it up.
- reboot
Upgrade Alpine to the Latest
When Alpine Linux is installed in sys mode, e.g. on a hard drive, upgrading to the next stable version should be a straightforward package manager operation. However, for specific info always refer to the appropriate release notes.
- Open
RAMHost had 3.16.0 Alpine and the latest is 3.16.3,
so
/etc/apk/repositories
can stay as is. https://www.alpinelinux.org to see the latest version. apk update
apk upgrade
Install Basic Packages
apk add man-pages man-pages-posix mandoc-apropos mandoc-doc ed-doc
apk add openssh-doc
Setup SSH
Follow these steps at your discretion. I’m creating a private SSH key that allows me to SSH as the root user if I know the passphrase. I’m storing this passphrase in my OSX Keychain.
Generate a 60-character random password and copy to the clipboard (on OSX).
pwgen -s 60|pbcopy
Create an SSH key, pressing command-V to paste in the password.
cd ~/.ssh
ssh-keygen -f id_kvm2_rsa
Add the passphrase to OSX Keychain.
ssh-add --apple-use-keychain ~/.ssh/id_kvm2_rsa
Configure SSH-agent to use the OSX Keychain for this host.
cat >> ~/.ssh/config
Host testblog
HostName test.markbucciarelli.com
User root
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_kvm2_rsa
^D
Authorize the key on the target host.
rc-status
Runlevel: default
sshd [ started ]
...
ed /etc/ssh/sshd_config
g/^PermitRootLogin/ s/prohibit-password/yes/
wq
rc-service sshd restart
Back on laptop:
ssh-copy_id -i ~/.ssh/id_kvm2_rsa root@test.markbucciarelli.com
On KVM:
ed /etc/ssh/sshd_config
g/^PermitRootLogin/ s/yes/prohibit-password/
wq
rc-service sshd restart