Create valid PEM key from RSA Private key for Dreamweaver

If you created your RSA Public/Private keys on a mac, you might not be able to create a valid PEM key for some of your apps and this can result in the credentials being rejected when you try to connect to a server. You might see this message:

Error: An FTP error occurred – cannot make connection to host/ Your login or password is incorrect. Please check your connection information.

This guide shows you why this happens and how to get around this issue and generate a proper, valid PEM key.

Why this occurs:

The standard OpenSSH service that comes with MacOS can create public/private key pairs that work, but can’t be converted to valid PEM keys. So, if you then try to create a PEM version of your private key with this code (as suggested by this stackexchange article):

openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem

This will likely fail with this error:

unable to load Private Key
4699557376:error:0909006C:PEM routines:get_name:no start line:crypto/pem/pem_lib.c:745:Expecting: ANY PRIVATE KEY

Why this is a problem:

Dreamweaver and other FTP apps (like Cyberduck or Transmit) require a valid OpenSSH PEM private key in order to authenticate with a server. If you try and use a standard “id_rsa” private key, then you will likely get a username/password rejection error.

If you try to convert your existing id_rsa key that was created on MacOS to a PEM key, then this will also likely fail with an incorrect username/password error.

How to create a valid PEM key

Choose either of the approaches outlined below to solve this problem depending on if you want to convert your existing private key or create a new paid of public / private keys.

A. Convert your existing RSA private key to a valid PEM key:

If you have already created an RSA key pair and installed the public key on your server for access with terminal and filezilla, then you probably won’t want to create a new set of keys to reinstall. Thankfully you can convert your existing private key using the following command, which includes the -p flag:

ssh-keygen -p -m PEM -f ./id_rsa

Caution: this will overwrite your existing private key. Make a copy of your private key before running this command.

After running this, you will have a PEM private key to use in Dreamweaver or other FTP clients to succesfully connect to your server.

B. Create a new public private key pair with a valid PEM key

If you haven’t yet created your public/private key pairs, then this may be for you. Use the -p flag in the normal ssh-keygen command to create a private PEM key. This will be suitable for for use in Dreamweaver and other FTP apps that rely on a OpenSSH key format. The -m option as PEM will output the key as a PEM key:

ssh-keygen -f id_rsa -m pem -p -C USERNAME

Note: replace id_rsa if you want to use a different name for your public/private key pair.

Questions or comments? Let me know!