Skip to content

Instantly share code, notes, and snippets.

@MatiasVara
Last active June 23, 2025 21:01
Show Gist options
  • Select an option

  • Save MatiasVara/0b27f2ee947ff8064affc59c3185779b to your computer and use it in GitHub Desktop.

Select an option

Save MatiasVara/0b27f2ee947ff8064affc59c3185779b to your computer and use it in GitHub Desktop.
This gist presents how to connect to a VNC server of a VM in Xcp-ng/XenServer.
#!/bin/bash
# Use it as: ./forward-vnc.sh "VM-name"
# Connect a vnc client to 9999
# Note that sudo iptables -I INPUT -p tcp -m tcp --dport 9999 -j ACCEPT
uuid="$(xe vm-list name-label="$1" --minimal)"
domid="$(xe vm-param-get uuid="$uuid" param-name=dom-id)"
socat -d -d TCP4-LISTEN:9999,fork UNIX-CONNECT:/var/run/xen/vnc-"$domid"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment