Ssh crashes when called in windows service

I call the cmd file, which calls ssh to interact with the Linux machine. I use the .NET Process class for this. But when called in the Windows Service, the call fails:

 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 run the application as a console application.

What is the possible reason for this failure and how to fix it?

EDIT All Windows services should do - somehow kill a predefined daemon on a Linux machine

thanks

EDIT

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

+4
source share
2 answers

Perhaps this post will save time to deal with a similar problem. I finally found a solution that works for me. This is the ssh -n key

So instead

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

I used

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

It still looks like magic, but it works!

+5
source

Isn't that a credential access problem?

when you start your program as a console application, you use the access rights for the current user. however, the Windows service runs under a special user account (usually "SYSTEM") and, as such, does not receive the same access rights.

0
source

Source: https://habr.com/ru/post/1345337/


All Articles