I have an ubuntu server and a windows XP client running Cygwin. The server ssh's into the client and tries to execute a shell script with some params, with the following command:

ssh user@IP_ADDR 'sh /home/user/project/clientside 2 5 7 6 9 5 7 IP_ADDR'

where IP_ADDR is the IP address of client.
However, while doing so, I get the following error:

Access is denied.

Thinking this might be a user permissions error, I tried running sh /home/user/project/clientside 2 5 7 6 9 5 7 IP_ADDR on the client, on Cygwin, while logged in as user.
This works as expected.

Then I thought that this might be an error with the login that I use when I ssh into the client. So I executed this instead:

ssh user@IP_ADDR 'whoami'

and got back user.

This happened even after I did chmod -R 777 /home/user/project on the client, in Cygwin.

For kicks, I got on Cygwin on the client and did ssh localhost and manually executed sh /home/user/project/clientside 2 5 7 6 9 5 7 IP_ADDR.
This worked as expected.

However, when I did ssh IP_ADDR from Cygwin and did ssh localhost and manually executed sh /home/user/project/clientside 2 5 7 6 9 5 7 IP_ADDR, I get the same Access is denied. error.

Why is this happening? How can I fix this?

By the way, both the server and the client have each other's rsa public key for passwordless ssh

  • Can you post your client Cygwin /var/log/auth.log. Look for error related to the problem. – John Siu Dec 20 '12 at 2:42
  • I got the correct solution - check out my answer – inspectorG4dget Dec 20 '12 at 2:50

The problem is with they way windows services work.
This fixes the problem:

  1. Close Cygwin
  2. Go to windows services (services.msc on Run Dialog).
  3. Stop the CYGWIN sshd service
  4. Double click on CYGWIN sshd to enter the service properties
  5. Stop the service
  6. Under the Log On tab, ensure that Log on as is set to Local System account and Allow service to interact with desktop is checked
  7. Restart the service
  8. Restart Cygwin
  9. Go get a beer
| improve this answer | |
  • hmm....doesn't the cygwin ssh setup program do this for you? – mdpc Dec 20 '12 at 3:26
  • apparently it didn't do it for me - I had to do this on >=4 computers, and all of them needed this fix – inspectorG4dget Dec 20 '12 at 3:33

You can try ssh IP_ADDR sh echo lalala to just that indeed you can open an sh terminal. if it fails ... you know the reason. Also it would be helpful to give us a sample of /var/log/messages and /var/log/secure {or whatever log you think that will be useful}

| improve this answer | |
  • That's an interesting idea. I get /bin/echo: /bin/echo: cannot execute binary file when I attempt ssh user@IP_ADDR 'sh echo lala' – inspectorG4dget Dec 20 '12 at 2:18
  • I get this error despite the fact that /bin/echo.exe has 755 permissions – inspectorG4dget Dec 20 '12 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.