If you get an ‘invalid format’ error when trying to SSH in to a remote server using a private key file that you know is valid, it may be because the key was generated with PuTTY.
If the key begins with
PuTTY-User-Key-File and you are using SSH/openSSH (ie. command line SSH) to connect to your server, you will need to first convert the key file using the
puttygen tool that comes with PuTTY.
puttygen and load your existing private key file. From the menu, select Export OpenSSH key (force new file format). Then click Save private key and save your converted key file.
Examine the new key file. The format should begin with BEGIN OPENSSH PRIVATE KEY and look something like the picture shown above. You should now be able to log in to your server using your new key file.