[SOLVED] Virt-Viewer connection to Proxmox VMs from network clients

variableman

New Member
Jun 14, 2021
19
2
3
57
A noob question. I can easily connect to VMs via the ProxMox gui.

However, I'd like other people in the network to be able to use the VMs as well. How do they connect using the Spice Virt-Viewer?

I can't share the vv file so I'm scratching my stupid head a bit.

Thanks.

For clarity, here is a sample machine set up:

Untitled.png
 
Hi,
The ability to create a non-expiring virtviewer file would be much appreciated

I'm on windows and was on my way to make a vbs script that requests the .vv file from proxmox

While I was doing that, I found this thread and the reference to cv4cve-pepper

I tried it however it did not work for me despite many permutations of the command line parameters

1665298337892.png
This is as far as I made it


Here is also my script, it is not complete, I can't make the line "http.send strRequest" work

Code:
dim virtviewer,proxmoxhost,username,password,vmid,node
virtviewer="C:\Program Files\VirtViewer v11.0-256\bin\virt-viewer.exe"
proxmoxhost="proxmox.lan:8006"
username="root" '"root@pam"
password="XXXXXXX"
node="pam"
vmid="101"

Dim NamedArgs, UnnamedArgs, x
Set NamedArgs = WScript.Arguments.Named
Set UnnamedArgs = WScript.Arguments.Unnamed

'should only execute on missing parameters
 msgbox  "-u username. Default root@pam" & vbcrlf & _
         "-p password. Default ''" & vbcrlf & _
          "vmid: id for VM" & vbcrlf & _
         "node: Proxmox cluster node name" & vbcrlf & _
         "proxy: DNS or IP (use <node> as default)"


Dim ServerName, WorkstationName
For Each Arg In NamedArgs
  Select Case Arg
    Case "-u", "--username"
      username = NamedArgs.Item(Arg)
    Case "-p", "--password"
      password = NamedArgs.Item(Arg)
  End Select
Next

For x = 0 To UnnamedArgs.Count - 1
    if x = 0 then vmid=UnnamedArgs.Item(x)
    if x = 1 then node=UnnamedArgs.Item(x)
    if x = 2 then proxmoxhost=UnnamedArgs.Item(x)
Next

dim strRequest,proxmoxserverurl
strRequest="username%3D" & username & "%40pam%2password%3D" & password
proxmoxserverurl = "https://" & proxmoxhost & "/api2/json/access/ticket"

dim http
set http=createObject("Microsoft.XMLHTTP")
http.open "POST",proxmoxserverurl,false
http.setRequestHeader "Content-Type","application/json"
'http.setRequestHeader "X-Parse-Application-Id","XXXXXXXXXXXXXXXXXXXXX"

msgbox proxmoxserverurl & vbcrlf & strRequest
' this should be equivalent to DATA="$(curl -f -s -S -k --data-urlencode "username=$USERNAME" --data-urlencode "password=$PASSWORD" "https://$PROXY:8006/api2/json/access/ticket")"
http.send strRequest

' need to actually do something with this
If http.Status = 200 Then
    msgbox "RESPONSE : " & http.responseText
    responseText=http.responseText
else
    msgbox "ERRCODE : " & http.status
End If

'bash string parsing looks like a cat walking on a keyboard, why do 1980s programmers like punctuations more than the alphabet,
'convert to human readable vbs, it would really help to see what TICKET and CSRF are supposed to look like
'TICKET="${DATA//\"/}"
'TICKET="${TICKET##*ticket:}"
'TICKET="${TICKET%%,*}"
'TICKET="${TICKET%%\}*}"

'CSRF="${DATA//\"/}"
'CSRF="${CSRF##*CSRFPreventionToken:}"
'CSRF="${CSRF%%,*}"
'CSRF="${CSRF%%\}*}"

'strRequest="username%3D" & username & "%0Apassword%3D" & password
'proxmoxserverurl = "https://" & proxmoxhost & "/api2/json/access/ticket"

set http=createObject("Microsoft.XMLHTTP")
http.open "POST",proxmoxserverurl,false
http.setRequestHeader "Content-Type","application/json"

' convert below to 
' 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
msgbox proxmoxserverurl & vbcrlf & strRequest
http.send strRequest

' need to actually do something with this
If http.Status = 200 Then
    msgbox "RESPONSE : " & http.responseText
    responseText=http.responseText
else
    msgbox "ERRCODE : " & http.status
End If


dim parameters

'  need the above code to work before I can decode it back into virtviewer parameters

Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "virtviewer", parameters, "", "runas", 1
 
Hi,
The ability to create a non-expiring virtviewer file would be much appreciated

I'm on windows and was on my way to make a vbs script that requests the .vv file from proxmox

While I was doing that, I found this thread and the reference to cv4cve-pepper

I tried it however it did not work for me despite many permutations of the command line parameters

View attachment 42052
This is as far as I made it


Here is also my script, it is not complete, I can't make the line "http.send strRequest" work

Code:
dim virtviewer,proxmoxhost,username,password,vmid,node
virtviewer="C:\Program Files\VirtViewer v11.0-256\bin\virt-viewer.exe"
proxmoxhost="proxmox.lan:8006"
username="root" '"root@pam"
password="XXXXXXX"
node="pam"
vmid="101"

Dim NamedArgs, UnnamedArgs, x
Set NamedArgs = WScript.Arguments.Named
Set UnnamedArgs = WScript.Arguments.Unnamed

'should only execute on missing parameters
 msgbox  "-u username. Default root@pam" & vbcrlf & _
         "-p password. Default ''" & vbcrlf & _
          "vmid: id for VM" & vbcrlf & _
         "node: Proxmox cluster node name" & vbcrlf & _
         "proxy: DNS or IP (use <node> as default)"


Dim ServerName, WorkstationName
For Each Arg In NamedArgs
  Select Case Arg
    Case "-u", "--username"
      username = NamedArgs.Item(Arg)
    Case "-p", "--password"
      password = NamedArgs.Item(Arg)
  End Select
Next

For x = 0 To UnnamedArgs.Count - 1
    if x = 0 then vmid=UnnamedArgs.Item(x)
    if x = 1 then node=UnnamedArgs.Item(x)
    if x = 2 then proxmoxhost=UnnamedArgs.Item(x)
Next

dim strRequest,proxmoxserverurl
strRequest="username%3D" & username & "%40pam%2password%3D" & password
proxmoxserverurl = "https://" & proxmoxhost & "/api2/json/access/ticket"

dim http
set http=createObject("Microsoft.XMLHTTP")
http.open "POST",proxmoxserverurl,false
http.setRequestHeader "Content-Type","application/json"
'http.setRequestHeader "X-Parse-Application-Id","XXXXXXXXXXXXXXXXXXXXX"

msgbox proxmoxserverurl & vbcrlf & strRequest
' this should be equivalent to DATA="$(curl -f -s -S -k --data-urlencode "username=$USERNAME" --data-urlencode "password=$PASSWORD" "https://$PROXY:8006/api2/json/access/ticket")"
http.send strRequest

' need to actually do something with this
If http.Status = 200 Then
    msgbox "RESPONSE : " & http.responseText
    responseText=http.responseText
else
    msgbox "ERRCODE : " & http.status
End If

'bash string parsing looks like a cat walking on a keyboard, why do 1980s programmers like punctuations more than the alphabet,
'convert to human readable vbs, it would really help to see what TICKET and CSRF are supposed to look like
'TICKET="${DATA//\"/}"
'TICKET="${TICKET##*ticket:}"
'TICKET="${TICKET%%,*}"
'TICKET="${TICKET%%\}*}"

'CSRF="${DATA//\"/}"
'CSRF="${CSRF##*CSRFPreventionToken:}"
'CSRF="${CSRF%%,*}"
'CSRF="${CSRF%%\}*}"

'strRequest="username%3D" & username & "%0Apassword%3D" & password
'proxmoxserverurl = "https://" & proxmoxhost & "/api2/json/access/ticket"

set http=createObject("Microsoft.XMLHTTP")
http.open "POST",proxmoxserverurl,false
http.setRequestHeader "Content-Type","application/json"

' convert below to
' 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
msgbox proxmoxserverurl & vbcrlf & strRequest
http.send strRequest

' need to actually do something with this
If http.Status = 200 Then
    msgbox "RESPONSE : " & http.responseText
    responseText=http.responseText
else
    msgbox "ERRCODE : " & http.status
End If


dim parameters

'  need the above code to work before I can decode it back into virtviewer parameters

Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "virtviewer", parameters, "", "runas", 1
Hi,
open issue in https://github.com/Corsinvest/cv4pve-pepper/issues I will answer you.

best regards
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!