Proxmox API Post Commands

egp1042

New Member
Feb 25, 2025
2
0
1
Hello,

I've been working on a script to create LXC containers (ubuntu template) and then configure them using the API. While I got creation and start working, I'd like to be able to run a shell script on them. Because they do not have cloud init, I am unsure of the proper way to run commands on them.

If I open a terminal on the host node, I can run pct exec 130 -- bash -c 'touch test.txt'. This works fine. I've been using https://github.com/luthermonson/go-proxmox, and they provide a client.Post method. What does a proper JSON body look like for this, especially with my command? I can see this, https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/execute, but I'm unsure what it's supposed to look like because whatever I try always throws some error.

Thank you for your help.

Edit: Formatting, some more context:
- The end goal is to be able to run a command to fetch a bash script from a web server they can all access and execute it
- Currently, I cannot figure out what a POST body for the /node/execute endpoint should look like. The command should execute onto the specified container
 
Last edited:
Update: This is no longer a critical issue as I was able to use ssh keys to log in and run commands. However, I would still be interested in a feature like cloud init or better support for running commands through the API on containers