Running a script automatically upon installation

baptistemm

New Member
Nov 11, 2015
7
0
1
France
Hello,

is a there a way to run a script automatically at the creation of any container? For instance the script could install my public key in the root account and / or register the machine in my data-warehouse?

I use proxmox 4.2.x

Regards.
 
You can already provide ssh keys for the root account when creating a container with pct ("-ssh-public-keys filepath"), GUI integration will follow soon. You can also wrap the container creation inside a bigger script that does extra stuff after "pct create" was successfully called, with "pct mount" and "pct unmount" you even have direct access to the root file system of the container.
 
Sorry I didn't reply to you, thanks for the answer.

I looking a way more programmatical and without direct access to the host to perform the actions. I was thinking a post-install script (bash, python, whatever) that would be downloaded and perform modification on the guest.

Thanks anyway
 
as I said, you can already provide authorized ssh keys for the root account - with that you should be able to automate almost anything, including running arbitrary scripts inside the container. the only prerequisite is that the network of the container needs to be configured correctly, but the network is configurable from the API/GUI so no need for (root) access to the host here either.
 
That is not yet updated unfortunately.. the parameter for the "POST /api2/json/nodes/{node}/lxc" API path is called "ssh-public-keys", is a string type and contains one public key in openssh format per line.
 
Last edited:
Any chance to expand that? Even on 7.1, it is only one line - adding multiple keys would be great (especially as it is called KEY*S* :) )
 
you can add multiple keys - one PER line ;)
 
i upload my linux' ssh keyfile with 2 keys, they get merged into a single line.. :/
This is via the GUI, tho.
 
it's only a limitation in the GUI - this thread was about the API? that being said, the GUI should be possible to fix as well..
 

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!