Advertisement
metalx1000

QEMU Debian server with port forwarding

Mar 17th, 2024
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.91 KB | None | 0 0
  1. sudo apt install qemu-system
  2.  
  3. # get image
  4. wget "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-amd64.qcow2"
  5.  
  6. # start VM with port forwarding
  7. qemu-system-x86_64 -enable-kvm -m 1G -hda debian-12-nocloud-amd64.qcow2 -nic user,hostfwd=tcp::5022-:22
  8.  
  9. #in VM
  10. apt update
  11. apt install -y gpm nmap
  12. apt reinstall openssh-server
  13.  
  14. adduser newuser
  15.  
  16. # set PasswordAuthentication yes
  17. vim /etc/ssh/sshd_config
  18.  
  19. /etc/init.d/sshd restart
  20.  
  21. # webserver
  22. # start VM with port forwarding
  23. qemu-system-x86_64 -enable-kvm -m 1G -hda debian-12-nocloud-amd64.qcow2 -nic user,hostfwd=tcp::5080-:80
  24.  
  25. apt install apache2
  26.  
  27. # headless
  28. qemu-system-x86_64 -enable-kvm -m 1G -hda debian-12-nocloud-amd64.qcow2 -nic user,hostfwd=tcp::5080-:80 -nographic
  29.  
  30. # both ports forwarded
  31. 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement