Try to use termproxy via Python and websockets

leetcore

New Member
Jul 19, 2024
3
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?