5

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?

Vaibhav Desai
  • 2,618
  • 1
  • 16
  • 16

2 Answers2

1

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.

Balaji
  • 11
  • 1
0

Try this bruv ... pscp.exe -v -pw '

  • '********' + ' ' + 'C:/temp/test' + ' '
  • username + '@' + hostname + ':'

... you need to put -pw after all options before the filespec don't forget the spaces.

Steve0
  • 17
  • 7