Spice
For connect to vm in local host or remote host we can use the next script
from the proxmox forums.
Spice connection script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 | #!/bin/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" > spiceproxy
exec remote-viewer spiceproxy
|
Note
Examples
-u username. Default root@pam
-p password. Default ‘’
vmid: id for VM
node: Proxmox cluster node name
proxy: DNS or IP (use <node> as default)
Local Host Example
./connectVm.sh -u root@pam -p Mypass 9007
Remote Host Example
./connectVm.sh -u root@pam -p Mypass 500 m15277 207.244.226.77
Last update:
Nov 20, 2024