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!
:: Sorry to kind of hijack your thread ::
Hi,
Adding this comment only to let future searchers eventually find it quicker.
This problema also affects bamboo when adding SSH/RSA key to access bitbucket (or other) repositories over ssh connection.
If you create the SSH/RSA key with key-gen without the "-m PEM" parameter, you'll not be able to use the key in bamboo (at least as of version 6.8.1)
After creating the shared credential with the SSH/RSA Key, when you try to test the repository access, you'll get a error message as:
"Cannot decode connection params" (Testing Repository SSH connection from bamboo to bitbucket or github).
If you follow the instructions of Romain in this post, it will work.
Thanks Romain, for pointing it out.
Can confirm same issue in Bamboo 7.0.3.
I had to run
ssh-keygen -t ecdsa -b 384 -m PEM
and not just
ssh-keygen -t ecdsa -b 384
to get it to work with shared credentials
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.