Your Code. Your Rules.

Key Not Accepted

Unsupported key type - This key is too weak - Invalid public key format - This key has already been added - This key is too large.

Key Not Accepted

Symptom

Settings → Git Access → SSH Keys refuses the key with one of these messages:

Unsupported key type. Only Ed25519 and RSA (2048 bits or more) are accepted.
This key is too weak. RSA keys must be at least 2048 bits.
Invalid public key format.
This key has already been added.
This key is too large.

Cause

MessageCause
Unsupported key typeECDSA, DSA or another type: only Ed25519 and RSA keys are accepted
This key is too weakAn RSA key below 2048 bits
Invalid public key formatNot one complete public key line: the private key, a cut line, or extra text
This key has already been addedThe key is registered already, on your account or on another one: one key belongs to one account
This key is too largeThe pasted text is over the size limit, usually not a single key

Diagnose

Print the type and size of your public key:

ssh-keygen -lf ~/.ssh/id_ed25519.pub

The line starts with the size in bits and ends with the type, for example (ED25519) or (RSA).

Fix

Option A - Generate an Ed25519 key (recommended)

ssh-keygen -t ed25519

Paste the full content of the public file, one line starting with ssh-ed25519 AAAA:

cat ~/.ssh/id_ed25519.pub

Option B - Generate an RSA key of 4096 bits

ssh-keygen -t rsa -b 4096

Option C - Already added

The key works already if it is on your account. If it is on another account, generate a new key for this one.

Verify

The SSH Keys page shows SSH key added successfully. and lists the key with its fingerprint.

Prevent

  • Use one Ed25519 key per device and per account.

Related