我正在尝试使用WinSCP和PowerShell连接到SFTP服务器,并遇到以下问题
错误:SSH主机密钥指纹“ ssh-rsa 2048 ABCDE + I9v1 + pLxkhZkod6yAbEh0o7a8wlSsI + ABCDEF”与模式不匹配 /(((ssh-rsa | ssh-dss | ssh-ed25519 | ecdsa-sha2-nistp(256 | 384 | 521))(|-))?(\ d +)?(([[0-9a-f] {2 }(:|-)){15} [0-9a-f] {2} | [0-9a-zA-Z + /] {43} =)(;((((ssh-rsa | ssh-dss | ssh- ed25519 | ecdsa-sha2-nistp(256 | 384 | 521))(|-))?(\ d +)?(([[0-9a-f] {2}(:|-)){15} [0- af] {2} | [0-9a-zA-Z + /] {43} =))* /
加引号的字符串中的ABCDE和ABCDEF只是我遮住了指纹。
我已经检查了现有的SO响应( SSH host key fingerprint ... does not match pattern ... when using WinSCP .NET assembly in C# to download files,SSH host key fingerprint does not match pattern C# WinSCP),但它们并不适用。
我对正则表达式有一个模糊的知识,看起来它应该与我匹配,所以我希望我缺少一些简单的东西。我有'ssh-rsa',然后是一个空格(|-),然后是多个数字,然后是空格(\ d +),然后是匹配[0-9a-zA-Z + /] {43}的43个字符(事实上,我有一个43个字符的字符串,这使我觉得我拥有正确的指纹,只是缺少一些语法琐事。模式的整个后半部分只是前一个模式的重复,我假设是可选的,所以我不知道哪些内容未被接受?
答案 0 :(得分:1)
Base-64编码的SHA-256指纹needs to be padded with =
:
ssh-rsa 2048 ABCDE+I9v1+pLxkhZkod6yAbEh0o7a8wlSsI+ABCDEF=
不过请注意,自WinSCP 5.16(当前为RC)以来,不需要填充。
正如答案中提到的,您提到的两个问题都最重要,WinSCP can generate a code template包括适合您的正确指纹。