Marketing Cloud SSH Key Generation: Inconsistency between PuTTY and ssh-keygen

After spending two months back and forth with Salesforce Support, I have finally worked out that in order to upload an SSH key in Key Management, you have to use PuTTYgen, not ssh-keygen (on Mac).

Is someone able to explain to me how I can get ssh-keygen to generate the same kind of private RSA key as PuTTY?

Here's an example key that PuTTYgen created (and that Salesforce Marketing Cloud will happily accept):

-----BEGIN RSA PRIVATE KEY-----
MIIEoQIBAAKCAQEAj+derXf2g3PmS2+H+UCuPBt3YV29BUdFICznAcZUJxoMbf2q
670zwpIqoMt2+KnJxWMbs+miYpAjUJBwgr3HuFa2XrrDUJISDffXRpucOSArqSdz
6k6PyKKgZCqx1Cp7BdDsMB6NwJURfS/iqgcVUTpU0Q3kclySWgvspkaW5JwGM513
Bzt6ECZXYjbPC/3w0/kS8COBQFdOMVDhEvHoMoK6yHCnBTC+bRVemqV3WHDMYNbX
4Gg5Z7hjsXtrEgMMYtOlQrF/mZkEdcFVKpqujavl26mwyMG06FRZUQYvPmmcgGhy
J5PuwH2MJjo63vEflAf0MKBprJXSySmmTD0QqwIBJQKCAQBRrNTe/uXb59W8HLT1
QGLj2DzWZaKiIYgZLj3sQCHsrethBZhcSMpZrOfDC7I6Gy1UWthfMZOEDJ5r/vO/
038xRfjN+0xCfGscr0LVDDYSlbfqYoAPXQV/tj9bci2UGBxPaL1na0mI+qkPs2T4
t+mBIRth5UpOvutH3UEgGjn3XpoXggnos352fnklPrglwAmYnmaurzULUA8MeRDt
C00/b8ErmLVOdcJcccCdGsTkU0KBXZPtaw1sVNBF7hASoQuoNpmqOFOo9KfZzro+
ivAXCpmCQSJ3T3qMACIVVg4UxprpgROh6kfiHzIwLZtFEhVH/mQn726WZfbRoxbm
m20tAoGBAO6VYMtUEPaZ54EHAKKPovZLMzHgq3OX9vJN3d0z49zPxbTrtAY6cMVw
gQV2miYs3y46mdiC5gO/Q2paEBpM4JMXgPG8hWjXj0c4KyE4IE3eDJ69+sZsqEeS
ugejb49HOPsvNGvyyMfj6iTA5H2dItCJ8G529/OBx2MKiEU1PSnBAoGBAJpooLKf
Q5h0tVY+KTEtpxpjfgeSjH9v335TkYSGjGrmx1wuZm2Jp1ll5E7qq2P6zij5Kmhy
Drx734piTfd/vZWEeJiXNo+MKerWNijBPHCHBoHKeRtZH63MpkZjbLfq90c74uOd
nBXspZUQcxlmlhEpuNVCiLNSlLCuyyyM4d1rAoGBAKE0f6v6iACRgL725MDdl59+
6z1gc9h7b4Ef2xjrtaMI7V6Ra8zbYPQblXJk5LICpKKx+T9DsCwLnEDwvsWpkNIW
zL8C1q6ffHw6tVuidrEnVKKcCk64HqzmmV8bZw3IVu7oizQua/yuwMy5ryRxF4X8
Vlh55c4LlI8HHc3ls7RtAoGALefBEoJgND5fbKqyTOQPFa7gR3DB/F+HohjYPCgA
O3UK1jdO4kuEx4z+r62M5l9SDC5mjcELTMrhl9gJV2sqhmWnT/WamWEFiwFqDB3F
3EPRgIhNhKvLJdUO1qfv46a4N8WyJ/5srJJ2apYwDnhxzcBLtQXxShGh06mWWVpQ
/KMCgYAauXmOmtv+nq+wZD8Iz8cEZVB4T7Hq0+2rdLuHRZK8NiqEK+TJWqSh3ASU
QplcsWdhI6lyAj52A9mHzl3KMwXpdJaQzsb1Qy6hsNrjp80OpUwdFn47HR7nM2de
+dTldYpwQ+mF98P3INN0VeNBj2Zon+/1NAjDxEMDur1tEn/EGw==
-----END RSA PRIVATE KEY-----

And here's the key that ssh-keygen -t rsa -b 2048 is giving me:

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
NhAAAAAwEAAQAAAQEA4EEMDSLlscX+/ZMwE/+VNuNYyWPMOks1uW/76zRyYmEmYNPh+WC6
m+/TtisPrsHqmw8WxyGSsp/zDwQ8NBLIbuXOmwQYSwVeveqhcowY/thpqKJ5kmp06gCIH6
rCh8b5+rf8i53UsLrPK1RwDoTWAK6Pn4F74OIMUJb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GiHmzaOgn1NB8cT/I
LiE+C6VefXHQAAAIEA/hVGc5lkVy8299TiNnL4i6+hYf/CLHeTaMaHNU7AoDxjLUxdmiO4
/txqBBeDUeoG1dq/jCIYM2pRocBYXJON0bRPkqgZRX4l+BFtGd7RSjfXeVYLM8UFZrjMNJ
rOf9ESdbOlsRPmzDwDBkFNhoIBW4SzN++L95oM8iJ6d9GCBxcAAACBAOHyKVQo2Com+c70
FN3k0sXjFUq9zXmau2CYW+A8OFtxWWGEiuxf7FL6oTOh1WcqWbi/JegJnVOIShnjn5crQe
FzDxDghA53V0qDOwJxo8T84wKEN1ZudykRAm1rNV7zW+xLhqR0qEg/SVMjNM8JrIYI96LT
FVNvA3COspvHf50HAAAAGGphbWVzYUBzdXFsZC1sMDEwOC5sb2NhbAEC
-----END OPENSSH PRIVATE KEY-----

Quick observation says that the BEGIN RSA and BEGIN OPENSSH titles are different. It also appears that PuTTY does it's line-breaks at 65 characters and ssh-keygen breaks the line at 71 characters.

The exact instructions I used for creating the key in PuttyGen are as follows:

  1. Download PuTTYgen
  2. Click Generate and move the mouse to create randomness
  3. Once the key is generated, don't Save Private Key, but go to the Conversions menu and click Export OpenSSH Key
  4. Leave the passcode blank and save as a *.ppk file
  5. Upload to Key Management in Marketing Cloud.

Does anyone knows a trick to do this with ssh-keygen (so I don't have to keep borrowing a Windows machine)?


Latest versions of OpenSSH ssh-keygen (7.8 and newer) generate keys in a new format (BEGIN OPENSSH PRIVATE KEY).

Your software (Salesforce Marketing Cloud) does not seem to support that format.

Use -m PEM flag, to make new ssh-keygen generate the keys in the old format (like BEGIN RSA PRIVATE KEY):

ssh-keygen -m PEM -t rsa -b 2048

You can also use ssh-keygen to convert your existing key in the new format to the old format by "abusing" the -p switch:

ssh-keygen -p -f file -m PEM -P passphrase -N passphrase

(if the key is not encrypted with a passphrase, use "" instead of passphrase)


PuTTYgen can also generate both formats. But, unless you use the command with "(force new file format)" or unless you generate Ed25519 key (not supported by the old format), it defaults to the old format. That was also the behavior of ssh-keygen in 6.5–7.7.

Btw, there's also a command-line Linux puttygen.