invalid_ssh_key
HTTP 422 SSH public key is not valid
What happened
The public key material you sent is not a valid OpenSSH public key. You get this when adding a key to your key pool, which is shared by all your projects, and for an item of ssh_public_keys - keys sent as text when creating a server, adding keys to it or reinstalling it; then detail starts with the item number. The key must not contain control characters (C0 or C1, U+0085 included - a tab between the key material and the comment too), line separators or U+FFFE/U+FFFF, and the comment after the key material must not contain ": " or a trailing ":": the key is written into the server's cloud-init data, where such a comment breaks it. Keys sent as text must not be DSA keys (ssh-dss): the hypervisors run OpenSSH 10, which no longer reads them. The line must start with a supported key type - ssh-ed25519, ssh-rsa, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521 or ssh-dss, in lower case - followed by a single space; other types, including FIDO keys (sk-ssh-ed25519@openssh.com, sk-ecdsa-sha2-nistp256@openssh.com), are not accepted. The whole key is checked, not only its start: the base64 body must decode, must not be cut short or carry extra bytes, and the key type inside it must match the type word in front of it - the detail field names which of these failed, and for an unsupported type it names the type and lists the supported ones, without repeating the key.
What to do
Send the single-line contents of the .pub file in public_key, or as one item of ssh_public_keys, - key type, base64 body, and an optional comment - copied whole, from one line. Never send a private key or a path to a file.
Retrying
Fix the request and send it again.
How it arrives
{
"type": "https://docs.fiberax.com/errors/invalid_ssh_key",
"title": "SSH public key is not valid",
"status": 422,
"code": "invalid_ssh_key",
"request_id": "a277dcd1ca652c65"
}
Branch your code on code, never on the wording of title.