开发者

ssh fails when is being called within windows service

I'm calling cmd file that calls ssh to intercommunicate with Linux machine. I use .NET Process class to accomplish this. But when being called within Windows Service call fails with following error:

C:\test>ssh -o StrictHostKeyChecking=no -i private_linux_key user@host "ls" 
      0 [main] ssh 9496 fhandler_base::dup: dup(some disk file) failed, handle 0, Win32 error 6
dup() in/out/err failed

Everything works when I start application as Console application.

What may be possible reason of this failure and how to fix this?

EDIT All Windows service has to do - somehow kill predefined daemon on Linux machine

开发者_StackOverflow

Thanks

EDIT

Similar problem described there: http://www.velocityreviews.com/forums/t714254-executing-commands-from-windows-service.html


Maybe this post will save someones time to struggle similar problem. I've finally found solution that works for me. It is ssh -n key

So instead of

ssh -o StrictHostKeyChecking=no -i private_linux_key user@host "ls"

I've used

ssh -n -o StrictHostKeyChecking=no -i private_linux_key user@host "ls"

It still looks like a magic, but it works!


isn't it a problem of access credentials ?

when running your program as a console applicaiton, you are using the access rights of the currently logged on user. however, a Windows Service executes in a special user account (generally "SYSTEM"), and as such is not granted the same access rights.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜