psftp 说 "The server's host key is not cached in the registry"
psftp says "The server's host key is not cached in the registry"
我在尝试使用 psftp
从 PowerShell 连接到 SFTP 服务器时收到以下消息:
错误:
psftp.exe : The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is.
The server's rsa2 key fingerprint is:ssh-rsa 2048 41289438190410491
Connection abandoned.
PowerShell 脚本:
$Username = "Username"
$Password = "Password"
psftp.exe sftpserver -l $Username -pw $Password -batch -bc -b C:\batch\download.bat
(psftp.exe存放在c:\windows\system32)
我之前通过 PuTTY 和 WinSCP 从这台服务器通过 SSH 连接到这台服务器没有问题。但是,当 运行 通过 PowerShell 时,它不会连接。
该消息不是错误。
每个 SSH/SFTP 客户端都需要验证服务器的主机密钥。
甚至 PuTTY 和 WinSCP 也会在您第一次连接到服务器时要求您确定以验证主机密钥。
尽管 PuTTY 和 psftp 共享主机密钥缓存。您确定您在同一台计算机上使用同一本地 Windows 帐户使用 PuTTY 吗?
无论如何,要么:
- 运行 psftp 一次,没有
-batch
开关。检查主机密钥并确认您是否信任它。 psftp 将缓存主机密钥并从现在开始工作。
- 或者将带有可信主机密钥指纹的
-hostkey
开关添加到 PowerShell 脚本中的 psftp
命令。
另请参阅 Respond y(es) to psftp host key prompt (though the highest-scored answer by @vmitchell85 is wrong, see the answer by @GerriePretorius)。
我在尝试使用 psftp
从 PowerShell 连接到 SFTP 服务器时收到以下消息:
错误:
psftp.exe : The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is.
The server's rsa2 key fingerprint is:ssh-rsa 2048 41289438190410491
Connection abandoned.
PowerShell 脚本:
$Username = "Username"
$Password = "Password"
psftp.exe sftpserver -l $Username -pw $Password -batch -bc -b C:\batch\download.bat
(psftp.exe存放在c:\windows\system32)
我之前通过 PuTTY 和 WinSCP 从这台服务器通过 SSH 连接到这台服务器没有问题。但是,当 运行 通过 PowerShell 时,它不会连接。
该消息不是错误。
每个 SSH/SFTP 客户端都需要验证服务器的主机密钥。
甚至 PuTTY 和 WinSCP 也会在您第一次连接到服务器时要求您确定以验证主机密钥。
尽管 PuTTY 和 psftp 共享主机密钥缓存。您确定您在同一台计算机上使用同一本地 Windows 帐户使用 PuTTY 吗?
无论如何,要么:
- 运行 psftp 一次,没有
-batch
开关。检查主机密钥并确认您是否信任它。 psftp 将缓存主机密钥并从现在开始工作。 - 或者将带有可信主机密钥指纹的
-hostkey
开关添加到 PowerShell 脚本中的psftp
命令。
另请参阅 Respond y(es) to psftp host key prompt (though the highest-scored answer by @vmitchell85 is wrong, see the answer by @GerriePretorius)。