Skip to main content

Start LXC or VM on Proxmox via Shortcuts under iOS

Why & General stuff

From time to time I need to start an LXC container on Proxmox – the container only runs 30 minutes and then automatically shuts down again. It is used to accept incoming scans from my multifunction printer, converts to PDF and uploads via SFTP to a convenient location. As this software is quite hacked together and drivers are from the last decade I prefer to let it run only “on demand”.

It is a pain to start the LXC through the browser UI – so I looked for different options. For sure you also could use some SSH and script action but Proxmox also provides an API with API keys. And that is what I used to built a super simple shortcut in Shortcuts under iOS.

Documentation on how to use API tokens in Proxmox can be found here: https://pve.proxmox.com/wiki/Proxmox_VE_API#Example:_Use_API_Token

Better create a dedicated user for these operations or set appropriate API token permissions – whatever fits your use case.

 

Create a new API token

 

For this example I do NOT use privilege separation.

 

Copy both values – we need them shortly.

 

Create the shortcut

Basically you just define an URL to the appropriate LXC or VM. Documentation: https://pve.proxmox.com/wiki/Proxmox_VE_API

For example:

https://$DOMAIN/api2/json/nodes/$TARGET-NODE/lxc/$LXC-ID/status/start

Note: You have to define IP / Domain, the Proxmox node and the ID of the LXC. And as far as I know the SSL certificate has to be trusted / from a known CA for the shortcut to work. Welcome to iOS.

 

Then add “get contents of URL”.
In the Header you set “Authorization” to

PVEAPIToken=root@pam!token2=69ab8098-f2aa-455c-add3-e387aef0a47e

You will have to replace with your two values you copied before 😉

 

Closing

That’s it, place it on your homescreen and you can start your LXC container with the press of a button 🙌🏼

Leave a Reply

Your email address will not be published.