OpenSSH updates its default RSA key format, let's get prepared!
With versions of OpenSSH 7.8 and above, the private key file will start with
-----BEGIN OPENSSH PRIVATE KEY-----
Instead of
----BEGIN RSA PRIVATE KEY-----
The work around is to specify the format to the old PEM when generating the keys:
ssh-keygen -m PEM -t rsa -b 4096
The new format isn't currently compatible in the Access keys of a Bitbucket repository.
When I tried to connect to a repository using a key pair generated with
ssh-keygen -t rsa -b 4096
I go this error from the Bitbucket server:
Load key ".ssh/id_rsa": invalid format
git@bitbucket.org: Permission denied (publickey).
Quote from the release note of openSSH 7.8:
ssh-keygen write OpenSSH format private keys by default
instead of using OpenSSL's PEM format. The OpenSSH format,
supported in OpenSSH releases since 2014 and described in the
PROTOCOL.key file in the source distribution, offers substantially
better protection against offline password guessing and supports
key comments in private keys. If necessary, it is possible to write
old PEM-style keys by adding "-m PEM" to ssh-keygen's arguments
when generating or updating a key.
The version 7.8 is currently on Arch Linux but when it will hit the main distributions Ubuntu, Fedora, Debian it might create a lot of confusion.
Bitbucket should try to be compatible beforehand. Or in the meantime update the command line documentations to use the "-m PEM".
I hope this will help!