1

The idea is to get rid of the CYGWIN warning given when one connects to the cygwin deamon running as a service in the windows box (sshd):

Problematic case:

> ssh -i <my private key> me@server "ls d://path//to//folder//"
cygwin warning:
  MS-DOS style path detected: d://path//to//folder//
  Preferred POSIX equivalent is: /cygdrive/d/path/to/folder/
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
  http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
[...]

This warning can cause a remote command executed to return a warning instead of '0' status code.

The warning tells us to set the following value in the CYGWIN environment variable: "nodosfilewarning"

The problem is that wether one sets it in any the following places, it does not get into the remote environment:

  • Windows user environment variables
  • Windows System environment variables
  • ~/.bashrc
  • ~/.profile
  • /etc/bashrc
  • /etc/profile etc.

Test case:

> ssh -i <my private key> me@server "env | grep CYGWIN"
CYGWIN=CYGWIN sshd

The CYGWIN environment variable never contains the proper value regardless of where you set it...

4

1 回答 1

2

The problem comes from the fact that sshd is run with cygrunsrv.exe which is set up from calling in the CYGWIN terminal ssh-host-config. It sets at install time a default value for the CYGWIN environment variable if not modified with the -c flag... or if it is not modified when Queried from the ssh-host-config script execution:

*** Query: Enter the value of CYGWIN for the deamon: [] CYGWIN sshd

See the ./bin.ssh-host-config script for the options and details.

 --cygwin -c <options>  Use \"options\" as value for CYGWIN environment var

Modifying the CYGWIN environment variable without un-installing the service and re-doing the installation with the -c flag is not possible as far as I know! Modifying the parameters of the service once installed is however possible if you edit the registry value found here:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\sshd\Parameters\Environment CYGWIN

Modifying the entry and appending nodosfilewarning at the end of the value will fix our problem!

We can verify that it has indeed worked by re-executing the test case again:

> ssh -i <my private key> me@server "env | grep CYGWIN"
CYGWIN=CYGWIN sshd nodosfilewarning

From then on, executing the problematic case should not display the warning message anymore!

于 2013-11-25T19:24:59.780 回答