Create LXC container : SSH public key - "failed to recognize ssh key" error

shodan

Member
Sep 1, 2022
86
32
23
Hello,

I would like to know how to get around this minor annoyance.
When creating a CT, I like to pre-load my ssh key files.
I make them with puttygen and save as a .ppk and .public file

However, the proxmox webui does not accept these key formats even though they are all very similar
I was wondering if there maybe was a way to make proxmox accept them, maybe reformat them appropriately.

If I hadn't been cursed with only being about in microsoft language, I think I could do it myself, but alas !

So, what proxmox wants is the openssh format and it looks like this

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCTuxHGK3Nv/KYDy2uYXNuc6BJ3BaTjELQnlvZP/8oICEVcClbepjcDc9rFiM1fsNwrmYF30FErgHlamITw8jNNu9KDvYKuAALCjAP3hjxlDr3I6UYYmlc9Vic8MNxXG3JehIv6+g1gRVLOMJybH445fgIrXVwpr3XT8MmWUCe0obbhivMLBTl31SKu6mhOXtePrK205b63BXz4GYC1y6sCfSIiK/wiaCUkRY9Dq54D8zykEVrb/yZ/9Rgimt8vHf9pJVHsGIY0vqGY5/PxAOdZJaJnZhw0QJRj1swSfNa96FeVGS/sF5/AQ0cqzgdTshLxWJROck7CAQS+ojeMOnm7 rsa-key-20220901

Here is the public key file format

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20220901"
AAAAB3NzaC1yc2EAAAADAQABAAABAQCTuxHGK3Nv/KYDy2uYXNuc6BJ3BaTjELQn
lvZP/8oICEVcClbepjcDc9rFiM1fsNwrmYF30FErgHlamITw8jNNu9KDvYKuAALC
jAP3hjxlDr3I6UYYmlc9Vic8MNxXG3JehIv6+g1gRVLOMJybH445fgIrXVwpr3XT
8MmWUCe0obbhivMLBTl31SKu6mhOXtePrK205b63BXz4GYC1y6sCfSIiK/wiaCUk
RY9Dq54D8zykEVrb/yZ/9Rgimt8vHf9pJVHsGIY0vqGY5/PxAOdZJaJnZhw0QJRj
1swSfNa96FeVGS/sF5/AQ0cqzgdTshLxWJROck7CAQS+ojeMOnm7
---- END SSH2 PUBLIC KEY ----

And here is the private key format (passphrase is passphrase)

PuTTY-User-Key-File-3: ssh-rsa
Encryption: aes256-cbc
Comment: rsa-key-20220901
Public-Lines: 6
AAAAB3NzaC1yc2EAAAADAQABAAABAQCTuxHGK3Nv/KYDy2uYXNuc6BJ3BaTjELQn
lvZP/8oICEVcClbepjcDc9rFiM1fsNwrmYF30FErgHlamITw8jNNu9KDvYKuAALC
jAP3hjxlDr3I6UYYmlc9Vic8MNxXG3JehIv6+g1gRVLOMJybH445fgIrXVwpr3XT
8MmWUCe0obbhivMLBTl31SKu6mhOXtePrK205b63BXz4GYC1y6sCfSIiK/wiaCUk
RY9Dq54D8zykEVrb/yZ/9Rgimt8vHf9pJVHsGIY0vqGY5/PxAOdZJaJnZhw0QJRj
1swSfNa96FeVGS/sF5/AQ0cqzgdTshLxWJROck7CAQS+ojeMOnm7
Key-Derivation: Argon2id
Argon2-Memory: 8192
Argon2-Passes: 21
Argon2-Parallelism: 1
Argon2-Salt: d5510cbfd45cc4cad08496690db4692e
Private-Lines: 14
zIr/x2RdITrHkrnIUz3FLVYwVKTiGn84c86pPZHL89W/Cab+GAbPYELQyfQ6LLH7
pAtuxG3SVhfClLi4saM4q0uxlfdigM/AFw9ec1uQdnF/h0bwCNlrOBjFyF4YupWE
JlPujLTuQaLB4RdAalIRJsiK1VcGuqLndM0fKzQBYSWKd5Rnu0Hn2TpJ+/hDa3KG
IzRW7oKmImtgHz497tav9uH7E8F5xZADl2pBW31tBn5Asmbu8Tvc8HCBq5km5UWA
F+zPVU1BDQuIb7BFDYo4228laSGgCtENw4dNwtMq0f1PrZPGxZKvdKjJcbXwIyJC
nvEae+elKXQh3iB/0pHxpQzbDiP5qqemhC0HDHmYkoFobusmVTMq3dI8b/l2GQuu
fB3XWJpQ6ck4upT6ufdm8GpV2ltDSMzN0ikC39P6+V/QyGTKCITF5WV3r++LAdiH
kHomxVs6ju6h+j9H2tE9mPPQPz0PLmZbL/woqsENDdjR4USt0PheWsSUy3mEh110
/AluOyB723plfUe8c7kmSa3H+dVk+Nsj1DUXOyhpi3UvDZp5tcFM6lvKZQt8B89u
YKyThrEqh7XfewAUEc22f8AEZkAXDAbT1bpkPcIppTxXFEuw+HGsM5BWYga4IMb6
2cb343ZoTmQElkBbfEaJZPAj0OpaT5Gmwt5IzCkcQofUIml9aWsLWTLaqXuNEr1I
LmsmeRHSkfcdvJ/zSp/nYOyudX4XqFgOSOUORqpNQJi4JMisH7jsoRC153qMo5fY
Ttp8yRe7iOX9qkXy33rNwqZCDSMKqJR1xi1A11B24ulzCG9Kv6hbBFSuKC5Ybvkb
YbuK/kv/ivYPb52CzJvcgKjceSThVnGJSW7B8bFLa8LerV0bdu6/afLGT0xIyD2U
Private-MAC: 4409d6d7f79796130ba016f106b2523cd4d8813e05df4c797b7fdf64dd44c041

So it seems it just needs to clip the file at the right place and it could accept this very common key format which most tutorials online end up producing.

So, unless maybe someone has already made a mod for this, I guess the first step is finding where is the web UI doing validation for that field ?
And maybe tack on a string substitution when the putty formats (and maybe other common formats ) are detected ?
 
Last edited:

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!