We have a Windows service running under the default Windows Local System account. This service tries to transfer a file to a server using pscp.exe. This is the exact command we fire:
pscp.exe -batch -r -q -v -l **** -pw **** C:/temp/test my-server-host-name:/bnrr2p3
Note the use of the --batch option to avoid any prompts. Now this fails because the server name has not been added to the known hosts list with the following error:
Looking up host "my-server-host-name"
Connecting to 10.89.3.108 port 22
Server version: SSH-2.0-Sun_SSH_1.1.4
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.62
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-1
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 1024 10:a8:36:6a:be:99:2c:e0:1c:18:80:28:c8:e5:dd:9b
Connection abandoned.
Disconnected: User aborted at host key verification
Lost connection
Google says I need to manually log on to that server first and add that server to the list. I can do this if I am running this as specific user.
How do I make it work for the Windows Local System account?
Use PsExec.exe -i -s cmd in the command prompt. The new command prompt will open with SYSTEM Default account. Run the command manually and accept the host key once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With