[SOLVED] pct create with multiple SSH keys

datdenkikniet

Member
Mar 28, 2020
25
6
23
25
Hi,

I'm trying to write a small script that'll automatically run "pct create" commands for me, so that I can set up containers a bit quicker and easily, and in order to figure out how promox' commands work.

I have, however, run into a small issue: I can't figure out how to specify more than one public ssh key (if that is at all possible). According to the manpage, I can use the option --ssh-public-key with "one file per line" in order to specify multiple ssh keys for the container, but I can't get it to work.

I have tried the following approaches so far:
Use the --ssh-public-key option twice (doesn't work, as expected only public key in specified with the second option is actually added)
Separate the files with a comma (i.e. --ssh-public-key <file1>,<file2>, didn't work as file can't be found due to comma)

I'm using PVE 6.1, and pveversion says I'm running "pve-manager/6.1-7/13e58d5e (running kernel: 5.3.18-2-pve)"

Another option would be to add a second SSH key after creating the container by pushing a new authorized_keys to the container or editing the file, but I think the one-command approach would be nicer, so I hope someone knows the solution.

Thank you in advance (and thank you for the amazing product. Have only been using it at home so far, but it's been great)


EDIT:
I managed to solve the problem. Turns out that you should have the two SSH keys in one file, at one per line, and can't specify multiple files.
 
Last edited:
  • Like
Reactions: Stoiko Ivanov
I have a related issue where i have decommissioned an old SSH key and would like to update authorized keys on each of my containers. I approached this by creating a 'foreach' loop for each container and using the 'pct push' command to copy the new auth key file. However, this only works for running containers. I'll have to adapt my script to be able to mount the filesystem (or maybe just use mount in the first place?).
 

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!