Mapping a virtualized guest port to a host port
- Download the Fedora Workstation ISO file from website and store it in a reference directory
cdromimg
.
- Start a virtual machine for mapping a virtualized guest port to a host port for the live ISO and there is no need for a virtual disk image here.
$ qemu-system-x86_64 \
-boot menu=on \
-m 4096 \
-cpu max \
-smp 4 \
-cdrom cdromimg/<Fedora-Workstation-Live-x86_64-xx-y.z.iso> \
-accel kvm \
-net nic \
-net user,hostfwd=tcp::2323-:22
- Wait for the virtual machine to boot up.
- In a new terminal session on the guest, execute the following command to the enable the
OpenSSH
service.
$ sudo systemctl enable --now sshd.service
- Now change the password of the current user by executing the following command in the terminal session on the guest.
- In a new terminal session on the host, execute the following command to connect to the guest using
SSH
.
$ ssh liveuser@localhost -p 2323
OR
In a new terminal session on a device connected to the same network, execute the following command to connect to the guest using SSH
.
$ ssh liveuser@<ip-address-of-the-host-device> -p 2323
- Execute the following command in to logout of the session.
- This was an example of mapping port 22 of the virtualized guest with port 2323 of the host with TCP for the purposes of SSH and this can be reused with slight changes to accommodate other use-cases.
Authors: Akashdeep Dhar, Jarek Prokop, Nick Dirschel