mirror of
https://github.com/proxmoxer/proxmoxer.git
synced 2026-04-25 15:16:01 +03:00
[GH-ISSUE #159] How to use ssh-public-key in pct create for lxc #84
Labels
No labels
backend:https
backend:local
backend:openssh
backend:ssh_paramiko
pull-request
status:ansible-issue
status:help-wanted
status:info-needed
status:proxmox-issue
status:review-needed
type:bug 🐞
type:dependency ⛓️
type:docs 📝
type:enhancement ⏫
type:maintenance 🛠️
type:meta
type:question ❓
type:request ✋
type:testing 🧪
version:1.x
version:latest
version:py2
version:py3
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/proxmoxer#84
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @harshguptaserver on GitHub (Mar 5, 2024).
Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/159
Originally assigned to: @jhollowe on GitHub.
Hello Proxmoxer team,
I have been using your python3 proxmoxer package to create pct container. However, while doing this I have been stuck at a place where i need to pass ssh-public-key argument while creating the lxc container.
This is mentioned in the Official Proxmox API here : https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/lxc
-- In POST Section as "ssh-public-keys"
My goal is to use ssh key to pass on to container creation ( as it is quite possible in the UI ).
Here is my sample code:
Despite trying multiple times/ multiple combinations for keyword 'sshpublickeys' it fails all the time with error:
@jhollowe commented on GitHub (Mar 5, 2024):
the ssh key(s) need to be encoded to make it through to PVE successfully. You can see how to do this in the cloud-init example docs.
Please reopen if this doesn't work for you.
@harshguptaserver commented on GitHub (Mar 6, 2024):
Thank you for the quick reply. I have already tried that earlier as well but it does not work for lxc.
Here is the sample code with the Encoded keys that I have tried:
and here is the error when using the above code:
As mentioned earlier, the property the lxc api is looking for is 'ssh-public-keys' per the api docs, in this case, there seems to be no such possibility to pass in the key.
Kindly help with the same and also how would one pass in multiple 'net' dynamically using python ?
i.e.
in the dictionary that has container data, we know there are say 3 net (net0, net1, net2) but how do we pass it dynamically from a python dictionary (as create uses arguments).
@harshguptaserver commented on GitHub (Mar 6, 2024):
@jhollowe please help in this regards, it will be very grateful of you & your team.
@morph027 commented on GitHub (Mar 6, 2024):
for lxc, its
ssh-public-keysSee https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/lxc
for multiple net, you could use python
enumerate()@jhollowe commented on GitHub (Mar 6, 2024):
and to be able to use hyphens in the key name, you will want to create the data as a dict and then unpack that into the
.post()/.create()call.e.g.
@harshguptaserver commented on GitHub (Mar 9, 2024):
Thank you so much @jhollowe & @morph027 , this resolved the issue of using ssh-public-keys, I can work on enumerate in my own time as I can use dict to create a ct now, it solves all the issues.
Really appreciate your quick responses and help :-)
For those who land on this issue, here is my code that works for creating lxc containers using dictionary :