Try to use termproxy via Python and websockets

leetcore

New Member
Jul 19, 2024
2
0
1
I'm trying to connect programmatically in Python with the webshell over API.

I first get an auth_ticket from API endpoint proxmox.access.ticket and a shell_ticket from API endpoint proxmox.nodes.localhost.termproxy.

I can successfully connect via websocket and the first message should be the termproxy shell_ticket with the username "root@pam" infront. Proxmox Backup Server should send "OK" but it's closing the connection afterwards.

Python:
self.ws.connect(
    f"wss://{self.hostname_port}/api2/json/nodes/{self.node}/vncwebsocket?port={str(self.shell_port)}&vncticket={urllib.parse.quote_plus(self.shell_ticket)}",
    cookie=f"PBSAuthCookie={self.auth_ticket}")
if self.ws.connected:
    self.ws.send_text(f"root@pam:{self.shell_ticket}")
    print(self.ws.recv())

Code:
++Rcv raw: b'\x88\x02\x03\xe8'
++Rcv decoded: fin=1 opcode=8 data=b'\x03\xe8'

Is there a documentation about the termproxy websockets protocol? I read https://github.com/proxmox/pve-xtermjs but i cannot get the first websocket message right.
 
Last edited:
it's probably missing the newline at the end of the ticket line?
 
You are right. I was missing the new line and the first message gets an OK now. Thank you!
 

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!