Windows Access is Denied to file created via ssh

1

1

I have a Windows server with cygwin installed and an sshd server running. I SSH in, and execute the following lines:

echo "Hello World!" > /cygdrive/c/Users/Administrator/Documents/helloworld.txt
chown Administrator /cygdrive/c/Users/Administrator/Documents/helloworld.txt
chgrp Administrators /cygdrive/c/Users/Administrator/Documents/helloworld.txt
chmod 777 /cygdrive/c/Users/Administrator/Documents/helloworld.txt
cmd /c "takeown /S localhost /U Administrator /P "@dm!np@$$" /F C:\Users\Administrator\Documents\helloworld.txt"

However, when I try to open the file in the Windows machine through an RDP session, I just get an "Access is denied" error. Any assistance is greatly appreciated.

jab416171

Posted 2012-07-03T16:07:34.573

Reputation: 11

Are you sure the commands are running ok? Check the return codes. For example the last one could fail due to the nested quotes – golimar – 2012-07-03T16:22:42.607

If I take out the /P switch and type in the password manually, the command just hangs. – jab416171 – 2012-07-03T16:44:19.097

In the RDP session, check what Windows permissions the file has. – Harry Johnston – 2012-07-04T00:38:01.573

Try with single quotes instead of double, for the password field or for the outer ones – golimar – 2012-07-04T08:59:59.660

I second the single quotes suggestion by @golimar. The $$ in the password (if that is indeed the password), will expand to the process id of the current shell. Single quotes will prevent that expansion. – Fran – 2012-07-11T18:39:37.453

No answers