Skip to main content

A python package that allows connecting and sending commands direcly to a proxmox node/lxc via vnc websocket.

Project description

logo

ProxVNC allows connecting and executing arbitrary commands directly on a Proxmox node/LXC via VNC WebSocket.

Installation

This package can be installed via PyPI:

pip install ProxVNC

Usage information

See the Examples folder for additional working examples.

Connecting via proxmoxer package:

First, create an object to connect to your Proxmox server. For more info read PROXMOXER documentation. All authentication methods are supported.. If you use an Api token you must set the permission to [Sys.console]

from ProxVNC.proxmoxer import ProxmoxAPI
from ProxVNC import ProxVNC
  
proxmox = ProxmoxAPI(host="<proxmox_host:port>", # ex: 10.0.0.1:8006
                         user="<username@realm>", # ex: "root@pam"
                         password="<password>",
                         otp=input("OTP: "),
                         verify_ssl=False)

Create a ProxVNC object and pass the proxmoxer connection via the api parameter. Optionally, specify which node to connect to.

    client = ProxVNC(api=proxmox, node="pve") # specify node if needed, otherwise first node is used by default
  
    client.connect()  

You are now connected! Here is a simple example of interacting with the terminal:

    print(client.readTerm())
    # --- Interact with terminal ---
    while True:
        cmd = input("Enter a command: ")

        if cmd.lower() in ["exit", "quit"]: # Keywords to exit
            break

        client.execCommand(cmd) # Execute the command
  
        print(client.readTerm()) # Read the terminal

    client.disconnect() # Don't forget to disconnect when you're done

Connecting direcly with a shell ticket:

You can also connect to the VNC terminal directly by POSTing to the Proxmox termproxy endpoint

In this example, PROXMOXER is used to call Proxmox API endpoints, but you can use requests or another package.

    proxmox = ProxmoxAPI(host="<proxmox_host:port>", # ex: 10.0.0.1:8006
                         user="", # ex: "root@pam"
                         password="<password>",
                         otp=input("OTP: "),
                         verify_ssl=False)
  
    termproxy = proxmox.nodes("pve").termproxy.post() # POST to termproxy with the node you want to connect to
  
    # Get shell ticket and port
    shell_ticket = termproxy["ticket"] 
    shell_port = termproxy["port"]

    pve_cookie, _ = proxmox.get_tokens() # Get cookie token

Once you have the required data, create the ProxVNC object manually:

    client = ProxVNC(
             url="https://<proxmox_host:port>",
             node="pve",
             user="<username@realm>",
             shell_port=shell_port,
             shell_ticket=shell_ticket,
             pve_auth_cookie=pve_cookie
            )  

     client.connect()

You can now start sending and receiving commands.

Sending files:

Using the sendFile(local_path: str, remote_path: str, wait_time=0.5) method, you can upload files to a specific location on your Proxmox node or LXC container.

    client.sendFile("testSend.txt", "/root/testReceive.txt")

Contributing

We welcome contributions! Here’s how you can help:

  1. Fork the repository and create a new branch for your feature or bug fix.
  2. Make your changes and ensure the code is clean and well-documented.
  3. Test your changes thoroughly before submitting.
  4. Open a pull request with a clear description of your changes.

Please follow PEP8 coding style and include examples if applicable.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proxvnc-1.1.1.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

proxvnc-1.1.1-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file proxvnc-1.1.1.tar.gz.

File metadata

  • Download URL: proxvnc-1.1.1.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for proxvnc-1.1.1.tar.gz
Algorithm Hash digest
SHA256 5270eb4e97dd4ab90678ba19f6e18c0088166bcb864eff61593db1fb43f0e456
MD5 3fcc71fea0782d744f58f533529a9836
BLAKE2b-256 3413194b2128db50d9d94ca9bfcedf4bbd529238d9ee486336e666d63839c3af

See more details on using hashes here.

Provenance

The following attestation bundles were made for proxvnc-1.1.1.tar.gz:

Publisher: python-publish.yml on xgiralt64/ProxVNC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file proxvnc-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: proxvnc-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for proxvnc-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f202c944b4d473e83e10aaf1fddf6c86cd5ce20989a39e926428d207af2b8b92
MD5 534abc6afb25aa3ff53e66c958aaff8e
BLAKE2b-256 78d7860f2fd16c473c9bc22075c07de3da3f4bf2559628e7aeed244eb35f1ae7

See more details on using hashes here.

Provenance

The following attestation bundles were made for proxvnc-1.1.1-py3-none-any.whl:

Publisher: python-publish.yml on xgiralt64/ProxVNC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page