pve-manager/spice-example-sh
2014-03-17 12:00:43 +01:00

26 lines
596 B
Bash
Executable File

#!/bin/bash
# needs pve-manager >= 3.1-44
USERNAME=root@pam
PASSWORD=yoursecretpassword
# select VM
VMID=100
NODE=anodename
PROXY=anodename.domain.tld
DATA=`curl -k -d "username=$USERNAME&password=$PASSWORD" https://$PROXY:8006/api2/json/access/ticket`
TICKET=${DATA//\"/}
TICKET=${TICKET##*ticket:}
TICKET=${TICKET%%,*}
CSRF=${DATA//\"/}
CSRF=${CSRF##*CSRFPreventionToken:}
CSRF=${CSRF%%,*}
curl -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" https://$PROXY:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy -d "proxy=$PROXY" > spiceproxy
remote-viewer spiceproxy