Skip to content

Instantly share code, notes, and snippets.

@tomdaley92
Last active December 20, 2024 20:02
Show Gist options
  • Save tomdaley92/789688fc68e77477d468f7b9e59af51c to your computer and use it in GitHub Desktop.
Save tomdaley92/789688fc68e77477d468f7b9e59af51c to your computer and use it in GitHub Desktop.
Proxmox - SPICE Client setup for MacOS

Proxmox - SPICE client setup for MacOS

  1. Install a working (and compiled) version of virt-viewer. You may view the homebrew package's upstream source on GitHub.

    brew tap jeffreywildman/homebrew-virt-manager
    brew install virt-viewer
  2. Once that's installed should be able make a call remote-viewer with a pve-spice.vv file downloaded from proxmox web interface

    remote-viewer pve-spice.vv

    Check out this useful script for debugging. There are also several other cli tools like this one on GitHub that can be used to test the same sort of thing.

Improving Quality of Life

We want remote-viewer to automatically start and open the session when we double click the VM entry in proxmox. To do that we need to first create a small helper application.

  1. Launch Automator and select Application from the dropdown list, when prompted.

    Screen Shot 2021-07-15 at 1 39 31 PM

  2. Search for shell and drag to the right. The contents:

    /usr/local/bin/remote-viewer "$@"

    Make sure to select as arguments for passing the input. Save as ~/Applications/pve-spice-launcher.app.

    Screen Shot 2021-07-15 at 2 13 01 PM

  3. Locate a pve-spice.vv file and right click, and go to Get Info -> Open With -> Change All, look for the .app file you just made.

    Screen Shot 2022-02-16 at 11 26 22 AM

  4. In Chrome, click on the small arrow on the list of downloads at the bottom, and select "Always open files of this type"

    Screen Shot 2021-07-15 at 2 02 46 PM

  5. If everything is set up correctly you should be able to double-click on the VM in the left pane of Proxmox and remote-viewer should start up and take care of the rest.

    Note: the pve-spice.vv files will be automatically deleted by remote-viewer

    Screen Shot 2021-07-15 at 2 05 57 PM

    Screen Shot 2021-07-15 at 4 42 21 PM

Enjoy!

#!/usr/bin/env bash
set -e
# needs pve-manager >= 3.1-44
usage() {
echo "Usage: $0 [-u <string>] [-p <string>] vmid [node [proxy]]"
echo
echo "-u username. Default root@pam"
echo "-p password. Default ''"
echo
echo "vmid: id for VM"
echo "node: Proxmox cluster node name"
echo "proxy: DNS or IP (use <node> as default)"
exit 1
}
PASSWORD=""
USERNAME=""
while getopts ":u:p:" o; do
case "${o}" in
u)
USERNAME="${OPTARG}"
;;
p)
PASSWORD="${OPTARG}"
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [[ -z "$PASSWORD" ]]; then
PASSWORD=""
fi
if [[ -z "$USERNAME" ]]; then
USERNAME='root@pam'
fi
DEFAULTHOST="$(hostname -f)"
# select VM
[[ -z "$1" ]] && usage
VMID="$1"
#[[ -z "$2" ]] && usage
NODE="${2:-$DEFAULTHOST}"
if [[ -z "$3" ]]; then
PROXY="$NODE"
else
PROXY="$3"
fi
NODE="${NODE%%\.*}"
DATA="$(curl -f -s -S -k --data-urlencode "username=$USERNAME" --data-urlencode "password=$PASSWORD" "https://$PROXY:8006/api2/json/access/ticket")"
echo "AUTH OK"
TICKET="${DATA//\"/}"
TICKET="${TICKET##*ticket:}"
TICKET="${TICKET%%,*}"
TICKET="${TICKET%%\}*}"
CSRF="${DATA//\"/}"
CSRF="${CSRF##*CSRFPreventionToken:}"
CSRF="${CSRF%%,*}"
CSRF="${CSRF%%\}*}"
curl -f -s -S -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" "https://$PROXY:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy" -d "proxy=$PROXY" > $NODE-$VMID.vv
exec remote-viewer $NODE-$VMID.vv
@fskale
Copy link

fskale commented May 3, 2024

It's not entirely related to this gist, but it would improve my quality of life greatly! I have a German keyboard layout Mac and whilst most characters work out of the box I cannot get \ and | working for the life of it. "<>" and "^°" are just switched but basically work. I tried to get it remapped using --keymap but even some of the most basic remappings I tried didn't work, like ALT or ALT_L modifiers were completely ignored. Does anybody have any experience with this and can point my into the right direction? Thanks!

It works, using my compiled app:

| -> right option key + ?
\ -> right option key + 7

Be sure to load the german keymap if not defined (console-data).
if not: loadkeys de

@TheQL
Copy link

TheQL commented May 3, 2024

It works, using my compiled app:

| -> right option key + ?
\ -> right option key + 7

Slightly different for me, but using the right option key was the hint I needed! Found what I searched for plus some brackets ;)

@jamesgreenblue
Copy link

Does this require rosetta?

@fskale
Copy link

fskale commented May 15, 2024

Does this require rosetta?

Not if you're using an Intel Mac.
Porting to ARM is still work in progress…

@TheQL
Copy link

TheQL commented May 15, 2024

Does this require rosetta?

Hm, the remote-viewer itself doesn't require Rosetta if you're using brew for arm. Not sure if any dependencies do, but thought that not.

# file /opt/homebrew/bin/remote-viewer
/opt/homebrew/bin/remote-viewer: Mach-O 64-bit executable arm64

@fskale
Copy link

fskale commented May 16, 2024

Does this require rosetta?

Hm, the remote-viewer itself doesn't require Rosetta if you're using brew for arm. Not sure if any dependencies do, but thought that not.

# file /opt/homebrew/bin/remote-viewer
/opt/homebrew/bin/remote-viewer: Mach-O 64-bit executable arm64

Sidenote.
The thing is, that the homebrew version doesn't support encrypted connections, which are used by OVIRT etc.
So i rebuilt the whole dependecy tree as well as the app itself.
Fyi.

@benjenj
Copy link

benjenj commented Jun 28, 2024

I'm using the BETA macOS 15.0, it won't work.
The command virt-viewer pve-spice.vv just gave me errors
(remote-viewer:54950): virt-viewer-WARNING **: 02:45:03.484: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)
Totally have no idea WTF it is after 10 hours tweaking.

@aanikolaeff
Copy link

All works fine on M2MAX except USB redirection. I got error "Could not redirect USB device: could not claim interface 0 (configuration 1): LIBUSB_ERROR_ACCESS (0)"

@fskale
Copy link

fskale commented Jul 18, 2024

I'm using the BETA macOS 15.0, it won't work. The command virt-viewer pve-spice.vv just gave me errors (remote-viewer:54950): virt-viewer-WARNING **: 02:45:03.484: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0) Totally have no idea WTF it is after 10 hours tweaking.

What version of gdk did you build remote-viewer with ?

@falconws
Copy link

Thanks very very usefull information

@byoung
Copy link

byoung commented Oct 16, 2024

I'm using the BETA macOS 15.0, it won't work. The command virt-viewer pve-spice.vv just gave me errors (remote-viewer:54950): virt-viewer-WARNING **: 02:45:03.484: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0) Totally have no idea WTF it is after 10 hours tweaking.

What version of gdk did you build remote-viewer with ?

I got the same error on MacOS 15.0.1

Here is my version of the only gdk package I could find in brew list.

$ brew info gdk-pixbuf
==> gdk-pixbuf: stable 2.42.12 (bottled)
Toolkit for image loading and pixel buffer manipulation
https://gtk.org
Installed
/usr/local/Cellar/gdk-pixbuf/2.42.12 (152 files, 3.3MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-10-16 at 13:32:49
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/gdk-pixbuf.rb
License: LGPL-2.1-or-later
==> Dependencies
Build: docutils ✘, gettext ✔, gobject-introspection ✔, meson ✔, ninja ✔, pkg-config ✔
Required: glib ✔, jpeg-turbo ✔, libpng ✔, libtiff ✔, gettext ✔

@globalhuman
Copy link

globalhuman commented Oct 28, 2024

I'm experiencing the same problem on MacOS 15.0.1

@lgzcoollg
Copy link

I got this warning and failed:

(remote-viewer:48032): virt-viewer-WARNING **: 10:42:12.312: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

@ThisIsJeron
Copy link

I guess some recent packages broke this - can't seem to connect with virt-viewer with the same errors as above

@timsonner
Copy link

I was getting this output. Fix included below…

(remote-viewer:1437): virt-viewer-WARNING **: 22:16:26.367: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)
2024-11-07 22:16:26.509 remote-viewer[1437:17842] +[IMKClient subclass]: chose IMKClient_Legacy
objc[1439]: Class ResultReceiver is implemented in both /usr/local/Cellar/gtk+3/3.24.43/lib/libgtk-3.0.dylib (0x103a61e40) and /usr/local/Cellar/gtk4/4.16.5/lib/libgtk-4.1.dylib (0x111ed3318). One of the two will be used. Which one is undefined.
objc[1439]: Class GtkApplicationQuartzDelegate is implemented in both /usr/local/Cellar/gtk+3/3.24.43/lib/libgtk-3.0.dylib (0x103a61e68) and /usr/local/Cellar/gtk4/4.16.5/lib/libgtk-4.1.dylib (0x111ed3340). One of the two will be used. Which one is undefined.
objc[1439]: Class GNSMenuItem is implemented in both /usr/local/Cellar/gtk+3/3.24.43/lib/libgtk-3.0.dylib (0x103a61eb8) and /usr/local/Cellar/gtk4/4.16.5/lib/libgtk-4.1.dylib (0x111ed3390). One of the two will be used. Which one is undefined.
objc[1439]: Class GNSMenu is implemented in both /usr/local/Cellar/gtk+3/3.24.43/lib/libgtk-3.0.dylib (0x103a61ee0) and /usr/local/Cellar/gtk4/4.16.5/lib/libgtk-4.1.dylib (0x111ed33b8). One of the two will be used. Which one is undefined.
objc[1439]: Class FilterComboBox is implemented in both /usr/local/Cellar/gtk+3/3.24.43/lib/libgtk-3.0.dylib (0x103a61f58) and /usr/local/Cellar/gtk4/4.16.5/lib/libgtk-4.1.dylib (0x111ed3430). One of the two will be used. Which one is undefined.
objc[1439]: Class gdkCoreCursor is implemented in both /usr/local/Cellar/gtk+3/3.24.43/lib/libgdk-3.0.dylib (0x102848688) and /usr/local/Cellar/gtk4/4.16.5/lib/libgtk-4.1.dylib (0x111ed3480). One of the two will be used. Which one is undefined.

FIX:
export GTK_PATH=/usr/local/Cellar/gtk+3/3.24.43/lib
export GTK_PATH=/usr/local/Cellar/gtk4/4.16.5/lib

Exporting the paths fixed error and I was able to remote in.

@Spoolingturbo6
Copy link

Does it need https:// ?

Proxmox 8.2.4
Guest Win11
Remote MacOs 14.7.2
browser Safari 17.6

Error: Unable to connect ( Unsupported graphic type "http" )
Address format http://192.168.1.70:xxxx

Lately I just been using MICROSOFT REMOTE DESKTOP for MacOs to connect to my Windows Vm's.
It's OK but connecting drops a lot. and at random. without provocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment