Easy, Working, KVM Remote Console

Why?

In my last post, I was lamenting that there really are not any lovely remote management interfaces to VirtualBox. I thought I would investigate nice remote management interfaces to KVM next. This investigation was more of a success.

What?

How?

There are a few ways to manage KVM VMs from Linux. The desktop app virt-manager is lovely but requires a shared desktop or X11 forwarding to use. Shared desktop is tricky for me as my host HDMI port is not always connected. X11 forwarding virt-manager had some VM console issues for me. The web GUI cockpit + cockpit-machines is also nice, but I had some issues with remote access to VM consoles. I decided to look at the KVM CLI commands and virt-viewer as a possible solution.

Create a VM

Here is the command to create a debian12 VM from an ISO. I configured 4 GB RAM, 4 vCPUs, a bridged network, disk files and ISO files residing on my NAS. I had a few Linux VM installs freeze if I did not give them at least 2 vCPUs.

macbook $ ssh dennis@nvidia-k8s

nvidia-k8s $ virt-install --hvm --name debian12-qemu --ram 4096 --vcpus 4 -f /media/asustor/kvm/debian12-kvm,size=20 --network bridge=br0 --cdrom /media/asustor/Proxmox/ISOs/debian-12.9.0-amd64-netinst.iso --graphics vnc,listen=0.0.0.0,port=5901 --noautoconsole

[I personally never got any of the --graphics console options to work - vnc, spice, none. I just use virt-viewer to connect ot the console]

Starting install...
Allocating 'blog-kvm'                                                                                              |    0 B  00:00:00 ... 
Creating domain...                                                                                                 |    0 B  00:00:00     

Domain is still running. Installation may be in progress.
You can reconnect to the console to complete the installation process.

nvidia-k8s $ virsh list --all
 Id   Name           State
-------------------------------
 14   blog-kvm       running
 -    budgie04-kvm   shut off
 -    budgie10-kvm   shut off
 -    debain12-kvm   shut off

Connect to the VM console

[From XQuartz on my Mac]
macbook $ ssh -Y dennis@nvidia-k8s

nvidia-k8s $ virt-viewer blog-kvm
[Console comes up in a window; complete the Linux installation from there]

All done

I have found that reboot does not actually reboot the VM but shut it down.

nvidia-k8s $ virsh list --all
 Id   Name           State
-------------------------------
 -    blog-kvm       shut off
 -    budgie04-kvm   shut off
 -    budgie10-kvm   shut off
 -    debain12-kvm   shut off

 nvidia-k8s $ virsh start blog-kvm

 nvidia -k8s $ virsh list --all
 Id   Name           State
-------------------------------
 15   blog-kvm       running
 -    budgie04-kvm   shut off
 -    budgie10-kvm   shut off
 -    debain12-kvm   shut off

 nvidia-k8s $ virt-viewer blog-kvm

Turn On Remote Desktop

Now virt-viewer is a little wonky with keyboard repeats on my Mac with X11 forwarding, so I am going to add NoMachine remote desktop. VNC and RDP don't currently play nice with the KDE Wayland Compositor.

dennis@blog-kvm: $ cd Downloads
dennis@blog-kvm: $ wget https://download.nomachine.com/download/8.16/Linux/nomachine_8.16.1_1_amd64.deb
dennis@blog-kvm: $ sudo apt install ./nomachine_8.16.1_1_amd64.deb

dennis@blog-kvm: $ sudo systemctl status nxserver
[sudo] password for dennis: 
● nxserver.service - NoMachine Server daemon
     Loaded: loaded (/lib/systemd/system/nxserver.service; enabled; preset: enabled)
     Active: active (running) since Tue 2025-04-01 17:31:52 EDT; 1min 0s ago
   Main PID: 9131 (nxserver.bin)
      Tasks: 31 (limit: 4620)
     Memory: 99.2M
        CPU: 716ms
     CGroup: /system.slice/nxserver.service
             ├─9131 /usr/NX/bin/nxserver.bin --daemon
             └─9193 /usr/NX/bin/nxd

Now I can use NoMachine from my Mac to connect to my new VM

Yay

Thank You

Thank you for reading this post. I hope this saves you some hassle in creating KVM VMs and accessing their consoles. I welcome your feedback and comments.