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.

  1. Login to your TinyKVM account.
  2. Note down the IP address, netmask and gateway.
  3. Pick “OS Manual Reload” icon.
  4. Select “alpine-extended-3.16.0-x86_64.iso” and click the Reload button.
  5. Wait a couple minutes.
  6. Click “Back to Main”.
  7. Click the “VNC Console” icon.
  8. Click “>> Launch NoVNC Client (recommended) <<”.
  9. Maximize the browser.
  10. You should see the Alpine Linux login prompt.

Setup Alpine

If you make a mistake, just press Ctrl-C and then restart setup-alpine.

  1. Login as root.
  2. Type setup-alpine at prompt and hit Enter.
  3. Enter the static IP / Gateway / Net Mask that you noted down above.
  4. (Google) for DNS server
  5. Enter “sda” for hard disk to use. I missed entering “sda” the first four times through the installer. ☹️
  6. “sys” for how you would like to use the disk.
  7. “y” erase disk and set it up.
  8. 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.

  1. Open RAMHost had 3.16.0 Alpine and the latest is 3.16.3, so /etc/apk/repositories can stay as is. to see the latest version.
  2. apk update
  3. 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
  User root
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_kvm2_rsa

Authorize the key on the target host.

Runlevel: default
 sshd                        [ started ]

ed /etc/ssh/sshd_config
g/^PermitRootLogin/ s/prohibit-password/yes/

rc-service sshd restart

Back on laptop:

ssh-copy_id -i ~/.ssh/id_kvm2_rsa


ed /etc/ssh/sshd_config
g/^PermitRootLogin/ s/yes/prohibit-password/
rc-service sshd restart

Tags: alpine ssh osx