在與 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
gQV2miYs3y46mdiC5gO/Q2paEBpM4JMXgPG8hWjXj0c4KyE4IE3eDJ69+sZsqEeS
ugejb49HOPsvNGvyyMfj6iTA5H2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mzaOgn1NB8cT/I
LiE+C6VefXHQAAAIEA/hVGc5lkVy8299TiNnL4i6+hYf/CLHeTaMaHNU7AoDxjLUxdmiO4
/txqBBeDUeoG1dq/jCIYM2pRocBYXJON0bRPkqgZRX4l+BFtGd7RSjfXeVYLM8UFZrjMNJ
rOf9ESdbOlsRPmzDwDBkFNhoIBW4SzN++L95oM8iJ6d9GCBxcAAACBAOHyKVQo2Com+c70
FN3k0sXjFUq9zXmau2CYW+A8OFtxWWGEiuxf7FL6oTOh1WcqWbi/JegJnVOIShnjn5crQe
FzDxDghA53V0qDOwJxo8T84wKEN1ZudykRAm1rNV7zW+xLhqR0qEg/SVMjNM8JrIYI96LT
FVNvA3COspvHf50HAAAAGGphbWVzYUBzdXFsZC1sMDEwOC5sb2NhbAEC
-----END OPENSSH PRIVATE KEY-----
快速觀察發現BEGIN RSA
和BEGIN OPENSSH
標題是不同的。 PuTTY 似乎也會在 65 個字元處進行換行,並ssh-keygen
在 71 個字元處進行換行。
我在 PuttyGen 中建立金鑰的具體說明如下:
- 下載普蒂根
- 點選產生並移動滑鼠來創建隨機性
- 產生密鑰後,不要保存私鑰,但是轉到轉換菜單並點擊導出 OpenSSH 金鑰
- 將密碼留空並另存為*.ppk文件
- 上傳到 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-keygen
6.5–7.7 中的行為。
順便說一句,還有一個命令列Linuxputtygen
。