QEMU DEBIAN SERVER WITH PORT FORWARDING

BACK


sudo apt install qemu-system
 
# get image
wget "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-amd64.qcow2"
 
# start VM with port forwarding
qemu-system-x86_64 -enable-kvm -m 1G -hda debian-12-nocloud-amd64.qcow2 -nic user,hostfwd=tcp::5022-:22
 
#in VM
apt update
apt install -y gpm nmap
apt reinstall openssh-server
 
adduser newuser
 
# set PasswordAuthentication yes
vim /etc/ssh/sshd_config
 
/etc/init.d/sshd restart
 
# webserver
# start VM with port forwarding
qemu-system-x86_64 -enable-kvm -m 1G -hda debian-12-nocloud-amd64.qcow2 -nic user,hostfwd=tcp::5080-:80
 
apt install apache2
 
# headless
qemu-system-x86_64 -enable-kvm -m 1G -hda debian-12-nocloud-amd64.qcow2 -nic user,hostfwd=tcp::5080-:80 -nographic
 
# both ports forwarded
qemu-system-x86_64 -enable-kvm -m 1G -hda debian-12-nocloud-amd64.qcow2 -nic user,hostfwd=tcp::5080-:80,hostfwd=tcp::5022-:22 -nographic