How to Setup Alpine Linux on Kernel-Based Virtual Machine
November 11, 2022
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.
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.
- 220.127.116.11 (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.
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.
RAMHost had 3.16.0 Alpine and the latest is 3.16.3,
/etc/apk/repositoriescan stay as is. https://www.alpinelinux.org to see the latest version.
Install Basic Packages
apk add man-pages man-pages-posix mandoc-apropos mandoc-doc ed-doc apk add openssh-doc
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 firstname.lastname@example.org
ed /etc/ssh/sshd_config g/^PermitRootLogin/ s/yes/prohibit-password/ wq rc-service sshd restart
Tags: alpine ssh osx