在 VBA + Excel 中使用 pscp.exe 将文件从 Windows 传输到 Unix 服务器时获取 "The server's host key is not cached in the registry"
Getting "The server's host key is not cached in the registry" when using pscp.exe to transfer file from Windows to Unix server in VBA + Excel
我已经在 Excel 上编写了 VBA 代码。我正在尝试使用 SFTP 和文件 pscp.exe 将文本文件传输到我的服务器。不会传输文件,显示pscp.exe的window。
我会看到以下消息:
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 XXXX XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection. Store key in cache? (y/n)
我该如何解决我的问题?
Dim Polku As String
Polku = "/"
Dim Palvelin As String
Palvelin = "grid1.example.xxx"
Dim Kayttajatunnus As String
Kayttajatunnus = "user@example.xxx"
Dim Salasana As String
Salasana = "Password2012"
Dim Tiedosto As String
Tiedosto = "filename.txt"
Dim PolkuOhjelma As String
Dim PolkuTiedosto As String
If Right$(ActiveWorkbook.Path, 1) <> "\" Then
PolkuOhjelma = ActiveWorkbook.Path & "\pscp.exe"
PolkuTiedosto = ActiveWorkbook.Path & "\" & Tiedosto
Else
PolkuOhjelma = ActiveWorkbook.Path & "pscp.exe"
PolkuTiedosto = ActiveWorkbook.Path & Tiedosto
End If
Dim Siirtokomento As String
Siirtokomento = Chr$(34) & PolkuOhjelma & Chr$(34) & " -sftp -l " & Kayttajatunnus & _
" -pw " & Salasana & " " & Chr$(34) & PolkuTiedosto & Chr$(34) & " " & _
Palvelin & ":" & Polku
Debug.Print Siirtokomento
Shell Siirtokomento, vbNormalFocus
您应该使用 -hostkey
switch 明确指定可信主机密钥的指纹。
-hostkey XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
我已经在 Excel 上编写了 VBA 代码。我正在尝试使用 SFTP 和文件 pscp.exe 将文本文件传输到我的服务器。不会传输文件,显示pscp.exe的window。
我会看到以下消息:
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 XXXX XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection. Store key in cache? (y/n)
我该如何解决我的问题?
Dim Polku As String
Polku = "/"
Dim Palvelin As String
Palvelin = "grid1.example.xxx"
Dim Kayttajatunnus As String
Kayttajatunnus = "user@example.xxx"
Dim Salasana As String
Salasana = "Password2012"
Dim Tiedosto As String
Tiedosto = "filename.txt"
Dim PolkuOhjelma As String
Dim PolkuTiedosto As String
If Right$(ActiveWorkbook.Path, 1) <> "\" Then
PolkuOhjelma = ActiveWorkbook.Path & "\pscp.exe"
PolkuTiedosto = ActiveWorkbook.Path & "\" & Tiedosto
Else
PolkuOhjelma = ActiveWorkbook.Path & "pscp.exe"
PolkuTiedosto = ActiveWorkbook.Path & Tiedosto
End If
Dim Siirtokomento As String
Siirtokomento = Chr$(34) & PolkuOhjelma & Chr$(34) & " -sftp -l " & Kayttajatunnus & _
" -pw " & Salasana & " " & Chr$(34) & PolkuTiedosto & Chr$(34) & " " & _
Palvelin & ":" & Polku
Debug.Print Siirtokomento
Shell Siirtokomento, vbNormalFocus
您应该使用 -hostkey
switch 明确指定可信主机密钥的指纹。
-hostkey XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX