Remote Spice access *without* using web manager

@frank lupo
When I execute the script in U20.04, it seems to execute but nothing happens. I tested it by putting in wrong passwords and wrong hosts and get errors, but when I put in all the right info, I get nothing:
./cv4pve-pepper --host=192.168.1.111 --username=root --password=secret --vmid 100 --viewer /usr/bin/virt-viewer
I'm using the following:
--host=IP of the Proxmox server
--username=same username as when logging in to Proxmox from the web interface
--password=same password as when logging in to Proxmox from the web interface
--vmid=virtual machine number in Proxmox

Is there a debug mode so I can find out what's going on?

Thanks,
Grant
Open issue on github. Exist parameter --debug

Best regards
 
Code:
#!/bin/bash

#
# SETTINGS
#
# Fill the following section with your prefered settings.
# Leaving the password field empty is much more secure. It will be prompted on the command line.
# Alternatively create a Proxmox user with limited privileges like shown in this template.
#
Great stuff.

Thanks a lot. It works very well on Ubuntu 20.04 and I can connect to my Proxmox VMs
 
Hi,
download release from from https://github.com/Corsinvest/cv4pve-pepper/releases

Best regards

Hi Frank,
I'm getting this issue while using the tool:

1604396804239.png

Somehow it appears in German language, the text is saying: "Could not establish connection to Grapics-server C:\users...."


I'm starting the executalbe as batch with the following args:

cv4pve-pepper --host=192.168.10.100 --username root@pam --password secret --vmid 101 --viewer "C:\Program Files\VirtViewer v9.0-256\bin\remote-viewer.exe"


If I look for the tmp7BA3.vv file in the temp folder, it's there, but the file is empty and has 0 KB.
I'm on PVE 6.2.12.


Any ideas?
Thx!
 

Attachments

  • 1604396756864.png
    1604396756864.png
    6.5 KB · Views: 4
Hi Frank,
I'm getting this issue while using the tool:

View attachment 20933

Somehow it appears in German language, the text is saying: "Could not establish connection to Grapics-server C:\users...."


I'm starting the executalbe as batch with the following args:

cv4pve-pepper --host=192.168.10.100 --username root@pam --password secret --vmid 101 --viewer "C:\Program Files\VirtViewer v9.0-256\bin\remote-viewer.exe"


If I look for the tmp7BA3.vv file in the temp folder, it's there, but the file is empty and has 0 KB.
I'm on PVE 6.2.12.


Any ideas?
Thx!


Found the issue, in case someone is interessted:

I used the --debug parameter to get some more info, what is happening.

It was a DNS problem. In my lab I didn't setup e proper DNS (it's a lab ;-) ). The output which came from PVE host returned not the IP, as used in the batch for running cv4pve-pepper.exe, rather then the DNS name:
1604403198237.png

But my client couldn't resolve pve.local, so no connect.
Quick & dirty, I edited the host file, and here we go, now it's working :)
 
Found the issue, in case someone is interessted:

I used the --debug parameter to get some more info, what is happening.

It was a DNS problem. In my lab I didn't setup e proper DNS (it's a lab ;-) ). The output which came from PVE host returned not the IP, as used in the batch for running cv4pve-pepper.exe, rather then the DNS name:
View attachment 20934

But my client couldn't resolve pve.local, so no connect.
Quick & dirty, I edited the host file, and here we go, now it's working :)

try using the --proxy parameter

Best regards
 
  • Like
Reactions: Docop2
Added a couple patches myself, see the diff.
So I am attempting to use these shell scripts in Linux Mint and Remmina 1.4.7. When I run the script with the Execute plugin with Remmina it appears to log in which I can see on the Syslog of PVE. It is able to start the VM if it's off, but my issue is with Remmina. According to Remmina's debug log it shows an entry like it's attempting to open a window to displace the VM, but nothing is occurring.

(rco_on_connect) - Trying to present the window
(rmnews_periodic_check) - periodic_rmnews_last_get is 1610925581
I'm not sure if the issue is with the script or if it's with Remmina or what I might be missing in my configuration for Remmina.
 
Added a couple patches myself, see the diff.
Thank you guys very much for your work. I like to contribute back. So if someone is interested in using the script with a PVEAPIToken instead of username/password I hacked the script to work with it.
 

Attachments

  • pve_spicetoken.sh.txt
    4.3 KB · Views: 77
Thanks for the example of using the API token, I modified my own bash script to switch now. I noticed that I am using a different call to get the spice configuration:
"https://$HOST:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy"
This does not seem to be documented anymore but still works. Anyone knows if it will be removed in the future? I would like to keep using it as it seems to be simpler than the other variant at least in bash, powershell might be different.

EDIT 11.03.2021:
I have created a Powershell script that works with the API Token and modified the bash script to my liking, I will share them here. Hopefully it will be of use to someone :)

EDIT 23.11.2021:
I updated the powershell script.
Just some additional info and a small change that should allow remote viewer 9 and 10 to run and probably newer/older versions too without specifying the exact location of the executable.
To find out more about custom spice paramaters check out: man remote-viewer

Mit freundlichen Grüßen | Best Regards
Jonas Stunkat
 

Attachments

  • pvespiceconnect.sh.txt
    3.3 KB · Views: 146
  • pvespice.ps1.txt
    2.6 KB · Views: 95
Last edited:
Hi Frank,
I'm getting this issue while using the tool:

View attachment 20933

Somehow it appears in German language, the text is saying: "Could not establish connection to Grapics-server C:\users...."


I'm starting the executalbe as batch with the following args:

cv4pve-pepper --host=192.168.10.100 --username root@pam --password secret --vmid 101 --viewer "C:\Program Files\VirtViewer v9.0-256\bin\remote-viewer.exe"


If I look for the tmp7BA3.vv file in the temp folder, it's there, but the file is empty and has 0 KB.
I'm on PVE 6.2.12.


Any ideas?
Thx!
HI,
use parameter --proxy

best regards
 
Hi
I use a script to connect to a virtual machine.
pvespiceconnect.sh
I swear there's no certificate. The server certificate was installed in firefox.
I can connect through a browser.
I have debian 10.10. I connect locally on the server itself.
Bash:
root@proxdol:/home/deb10# ./proxspice2.sh 100
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
root@proxdol:/home/deb10# Unable to init server: Could not connect: Connection refused

(remote-viewer:17010): Gtk-WARNING **: 14:08:31.287: cannot open display:

This script
https://gitlab.com/-/snippets/32412
Give error
Bash:
root@proxdol:/home/deb10# ./proxspice.sh -u root -p password 100 proxdol
---
curl: (22) The requested URL returned error: 401 authentication failure
password its true. Help me please.
 
Last edited:
Thanks for the example of using the API token, I modified my own bash script to switch now. I noticed that I am using a different call to get the spice configuration:
"https://$HOST:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy"
This does not seem to be documented anymore but still works. Anyone knows if it will be removed in the future? I would like to keep using it as it seems to be simpler than the other variant at least in bash, powershell might be different.

EDIT 11.03.2021:
I have created a Powershell script that works with the API Token and modified the bash script to my liking, I will share them here. Hopefully it will be of use to someone :)

Mit freundlichen Grüßen | Best Regards
Jonas Stunkat
I get a "tmpC789.tmp: Key file does not start with a group". Am I doing something wrong with the API Token?
 
I get a "tmpC789.tmp: Key file does not start with a group". Am I doing something wrong with the API Token?
I am guessing here but you probably try to use the Powershell script?
Well I think your "tmpC789.tmp" file has no or wrong contents.
I modified the script a little for better usage, I put in some additional info.

You could try to comment out the line where remote-viewer ist started and write somehing like this above that line:

Code:
echo $Tempfile.FullName
cmd /c "pause"
#Start-Process $rvpath $Tempfile.FullName

Output:
C:\Users\YOU\AppData\Local\Temp\tmp3EDD.tmp
Drücken Sie eine beliebige Taste . . .

You could then check the contents of the tmp file, it should look alike to what you can see in the file I have attached to this post.
The updated version of the Powershell script is in my original post.
https://forum.proxmox.com/threads/remote-spice-access-without-using-web-manager.16561/post-373159
 

Attachments

  • remote-viewer-connection.tmp.txt
    686 bytes · Views: 55
I'm having issues getting VMIDs.

When I execute:
Bash:
curl -f -s -S -k -H "${AUTHHEADER}" "https://${HOST}:8006/api2/json/nodes/${NODE}/qemu

I just get:
JSON:
{"data":[{"name":"aplinfo"},{"name":"apt"},{"name":"capabilities"},{"name":"ceph"},{"name":"certificates"},{"name":"config"},{"name":"cpu"},{"name":"disks"},{"name":"dns"},{"name":"firewall"},{"name":"hosts"},{"name":"journal"},{"name":"lxc"},{"name":"netstat"},{"name":"network"},{"name":"qemu"},{"name":"replication"},{"name":"report"},{"name":"rrd"},{"name":"rrddata"},{"name":"scan"},{"name":"services"},{"name":"spiceshell"},{"name":"startall"},{"name":"status"},{"name":"stopall"},{"name":"storage"},{"name":"subscription"},{"name":"syslog"},{"name":"tasks"},{"name":"termproxy"},{"name":"time"},{"name":"version"},{"name":"vncshell"},{"name":"vzdump"},{"name":"wakeonlan"}]}

I looked at the API documentation, but I can't see the issue.
 
I looked at the API documentation, but I can't see the issue.
it looks like your ${NODE} variable is empty thus querying: '/api2/json/nodes//qemu' which will discard the double '//' and interpret 'qemu' as the nodename. since for the listing of the subdirs there is no actual node necessary, it lists the
general node sub api paths.
 
it looks like your ${NODE} variable is empty thus querying: '/api2/json/nodes//qemu' which will discard the double '//' and interpret 'qemu' as the nodename. since for the listing of the subdirs there is no actual node necessary, it lists the
general node sub api paths.
That was exactly it. Much appreciated.
 
I get a "tmpC789.tmp: Key file does not start with a group". Am I doing something wrong with the API Token?
I have a similar issue using the bash script on Proxmox 6.4-13.

Bash:
(remote-viewer:36027): virt-viewer-WARNING **: 10:31:27.722: Invalid file /tmp/tmp.qmkBr6dDmo: Key file does not start with a group

tmp file attached
 

Attachments

  • tmp.qmkBr6dDmo.txt
    653 bytes · Views: 19
I have a similar issue using the bash script on Proxmox 6.4-13.

Bash:
(remote-viewer:36027): virt-viewer-WARNING **: 10:31:27.722: Invalid file /tmp/tmp.qmkBr6dDmo: Key file does not start with a group

tmp file attached
Look at my previous post and the file that is attached (https://forum.proxmox.com/threads/remote-spice-access-without-using-web-manager.16561/post-432572), this is how a connection file should look.
Yours basically has the correct information in it. Unfortunately its formatted incorrectly, looks like json to me. The call to the api works, the information received is valid too.

Did you change anything in the bash script? Which script exactly did you use?

Best Regards
Jonas
 
Thanks for the example of using the API token, I modified my own bash script to switch now. I noticed that I am using a different call to get the spice configuration:
"https://$HOST:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy"
This does not seem to be documented anymore but still works. Anyone knows if it will be removed in the future? I would like to keep using it as it seems to be simpler than the other variant at least in bash, powershell might be different.
[...]
Mit freundlichen Grüßen | Best Regards
Jonas Stunkat
Hi Jonas,

I'm trying to use your script, but there is no information how to create the necessary TOKEN and corresponding secret for pvespiceconnect.sh
Can you elaborate on how to get this information?

Cheers and thanks
Christoph.
 

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!