Loading...
Loading...
Guidance for setting up QEMU virtual machines with Alpine Linux and SSH access. This skill should be used when tasks involve starting QEMU with Alpine Linux ISO, configuring port forwarding for SSH, setting up OpenSSH server in Alpine, or troubleshooting QEMU networking issues.
npx skill4agent add letta-ai/skills qemu-alpine-ssh# Preferred methods (if available)
ss -tlnp | grep :2222
netstat -tlnp | grep :2222
lsof -i :2222
# Fallback when standard tools unavailable
cat /proc/net/tcp | awk '{print $2}' | grep -i ":08AE" # 08AE is hex for 222208AE001608AE1F90# Find QEMU processes
ps aux | grep qemu
pgrep -la qemu
# Kill all QEMU processes if needed
pkill -9 qemu-system
pkill -9 qemuls -la /path/to/alpine.iso
file /path/to/alpine.isoqemu-system-x86_64 \
-m 512 \
-cdrom /path/to/alpine.iso \
-boot d \
-nographic \
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
-device virtio-net-pci,netdev=net0tcp::[host_port]-:[guest_port]hostfwd=tcp::2222-:22hostfwd=tcp:127.0.0.1:2222-:22hostfwd=tcp:0.0.0.0:2222-:22rootpasswd
# Enter password twice when promptedsetup-interfaces
# Select eth0, dhcp, no manual config, done
ifup eth0setup-apkrepos
# Select a mirror (enter number) or 'f' for fastestapk update
apk add openssh/etc/ssh/sshd_config# Enable root login with password
sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_configrc-update add sshd
rc-service sshd start
# Or simply: /etc/init.d/sshd start#!/usr/bin/expect -f
set timeout 300
spawn qemu-system-x86_64 -m 512 -cdrom alpine.iso -boot d -nographic \
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
-device virtio-net-pci,netdev=net0
# Wait for login prompt
expect "login:"
send "root\r"
# Continue with setup commands...
expect "# "
send "passwd\r"
expect "New password:"
send "password123\r"
expect "Retype password:"
send "password123\r"
# IMPORTANT: End with 'interact' not 'interac)' or other typos
interactapk updateinterac)\r\nssh -p 2222 -o StrictHostKeyChecking=no root@localhost
# Or
ssh -p 2222 -o StrictHostKeyChecking=no root@127.0.0.1# Check QEMU process shows hostfwd
ps aux | grep qemu | grep hostfwd
# Check port is listening
ss -tlnp | grep 2222rc-service sshd status
netstat -tlnp | grep :22pkill qemu-systemrc-service sshd startrc-update add sshd/etc/ssh/sshd_configrc-service sshd restartsetup-interfacesifup eth0apk updatesetup-apkreposps aux | grep qemuss -tlnp | grep 2222ip addrrc-service sshd status/etc/ssh/sshd_configpasswd# Kill QEMU processes
pkill qemu-system
# Verify ports released
ss -tlnp | grep 2222 # Should return nothing
# Remove temporary files if created
rm -f /tmp/alpine-setup.exp