Marketing Cloud SSH 密钥生成:PuTTY 与 ssh-keygen 之间不一致

Marketing Cloud SSH 密钥生成:PuTTY 与 ssh-keygen 之间不一致

在与 Salesforce 支持人员来回沟通了两个月之后,我终于明白,为了在密钥管理中上传 SSH 密钥,您必须使用 PuTTYgen,而不是ssh-keygen(在 Mac 上)。

有人能向我解释一下如何ssh-keygen生成与 PuTTY 相同类型的私钥 RSA 密钥吗?

以下是 PuTTYgen 创建的示例密钥(Salesforce Marketing Cloud 很乐意接受):

-----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
gQV2miYs3y46mdiC5g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L94UyEFWKTlcRuy
/e/rSQuwA6sMaQDPEN/W8dzWQiepxZxzGm2yTDcZCgpVUcLxbwNURGiHmzaOgn1NB8cT/I
LiE+C6VefXHQAAAIEA/hVGc5lkVy8299TiNnL4i6+hYf/CLHeTaMaHNU7AoDxjLUxdmiO4
/txqBBeDUeoG1dq/jCIYM2pRocBYXJON0bRPkqgZRX4l+BFtGd7RSjfXeVYLM8UFZrjMNJ
rOf9ESdbOlsRPmzDwDBkFNhoIBW4SzN++L95oM8iJ6d9GCBxcAAACBAOHyKVQo2Com+c70
FN3k0sXjFUq9zXmau2CYW+A8OFtxWWGEiuxf7FL6oTOh1WcqWbi/JegJnVOIShnjn5crQe
FzDxDghA53V0qDOwJxo8T84wKEN1ZudykRAm1rNV7zW+xLhqR0qEg/SVMjNM8JrIYI96LT
FVNvA3COspvHf50HAAAAGGphbWVzYUBzdXFsZC1sMDEwOC5sb2NhbAEC
-----END OPENSSH PRIVATE KEY-----

快速观察发现BEGIN RSABEGIN OPENSSH标题不同。此外,PuTTY 似乎在 65 个字符处换行,并ssh-keygen在 71 个字符处换行。

我在 PuttyGen 中创建密钥的具体说明如下:

  1. 下载PuTTYgen
  2. 点击产生并移动鼠标来创造随机性
  3. 生成密钥后,不要保存私钥,但去转换菜单并点击导出 OpenSSH 密钥
  4. 将密码留空并保存为*.ppk文件
  5. 上传至 Marketing Cloud 中的密钥管理。

有人知道怎样做才能达到这个目的吗ssh-keygen(这样我就不必继续借用 Windows 机器了)?

答案1

最新版本的 OpenSSH ssh-keygen(7.8 及更新版本)以新格式生成密钥(BEGIN OPENSSH PRIVATE KEY)。

您的软件(Salesforce Marketing Cloud)似乎不支持该格式。

使用-m PEM旗帜,使新ssh-keygen生成的密钥以旧格式存在(如BEGIN RSA PRIVATE KEY):

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

您还可以ssh-keygen通过“滥用”-p转变

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

(如果密钥未使用密码加密,则使用""而不是passphrase


PuTTYgen 也可以生成这两种格式。但是,除非您使用带有“(强制使用新文件格式)”或者,除非您生成 Ed25519 密钥(旧格式不支持),否则它将默认为旧格式。这也是ssh-keygen6.5–7.7的行为

顺便说一下,还有一个命令行 Linuxputtygen

相关内容