我想将pscp
一些文件从 Windows 传输到 Linux 服务器。以下代码(PowerShell)是我正在尝试的。它工作得很好,但我需要输入y,当它试图与远程服务器通信时,因为 Windows 的主机名是未知的。
$proc = Start-Process powershell.exe -Credential $credential -ArgumentList "Start-Process C:\pscp.exe -Verb RunAs -ArgumentList '-i C:\prikey.ppk D:\temp\* corey@11.22.33.44:/home/corey/' -Wait" -PassThru
$proc.WaitForExit()
它将显示如下内容:
服务器的主机密钥未缓存在注册表中。您无法保证服务器就是您认为的计算机。服务器的 ssh 密钥指纹为:xxxxxx 如果信任此主机,输入“y”将密钥添加到 PuTTY 的缓存中并继续连接...... 将密钥存储在缓存中?(是/否)
有没有办法在echo "y"
使用时自动(非交互式)Start-Process
?或者禁用 Windows 的 SSH 主机检查(对我来说更好)?
任何帮助表示赞赏。