When you connect to a remote SSH host from Windows using the PuTTY client, you may receive an error message about an incompatible private key format:
Unable to use key file (OpenSSH SSH-2 private key (old PEM format))
Or:
Unable to use key file (OpenSSH SSH-2 private key (new format))
The format of SSH keys generated by ssh-keygen is not supported by PuTTY.
You need to convert your SSH key to the PuTTY format to solve this problem. This is done using the PuTTYGen tool.
- Run the
puttygen.exe
; - Select Conversions -> Import key and specify the file containing your private RSA key;
- Then click Save private key and save the key in .ppk format (if necessary, you can set a password to protect the key);
- Now run the PuTTY client and go to Connection -> SSH -> Auth. Select your PPK key file in the Private key file for authentication field.
- Try connecting to a remote SSH host and make sure the Unable to use key file error is gone.
In some cases, PuTTY may return another error when connecting to a host using an SSH key:
Couldn't load private key - Putty key format too new.
This usually means that you have generated a key for SSH protocol 3 and are trying to connect to a host using SSH 2. SSH-1, SSH-2, and SSH-3 key formats are different.
To fix the problem, try changing your preferred SSH version in the PuTTY settings.
Or you can use PuTTYGen to convert the format of the key:
- Import your key file and select Key -> Parameters for saving key files;
- Change the option in PPK file version -> 2
- Save your PPK file and try to connect to the host using SSH.