public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Issue running PowerShell code on Windows Machine from Linux machine using Cygwin
@ 2018-07-30 15:53 Shekhar Shukla
       [not found] ` <59d985e9-7702-cbdb-8da5-8c825def9064@gmail.com>
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Shekhar Shukla @ 2018-07-30 15:53 UTC (permalink / raw)
  To: cygwin

 Hi Team,

I am having issue while establishing a ssh connection from Linux to Windows
machine using Cygwin. My powershell script works when I run it from Linux
using ssh connection(Cygwin) to Windows  and manually enter my passowrd.
But whn I use public key to authenticate my user(making a password less
connection), it fails. Is it a bug with CYgwin?

Below is the step by step explantion-


1. Sample
Code
I have put on Windows machine. This machine has Cygwin installed on it

+++++++++++++
:
+++++++++++

echo "Hello World!"
import-module ActiveDirectory
get-adcomputer -Filter * |select Name|select -first 10
+++++++++++++++++++++++++


2. When I run
this code
 from Linux machine using Cygwin WITHOUT enabling password-less connection,
It asks for password
of Windows machine and after entering the password it
 execute
s
 like a charm. See below-

+++++++++++++++++++++++

shekhar@LinuxBox:~$ ssh shekhar@WindowsBox.doamin.com 'powershell
"C:/scripts/abc.ps1"'
shekhar@WindoxBox.domain.com's password:

Hello World!

Name
----
Server1
Server2
Server3
Server4

++++++++++++++++++++++++

3. Now I generate an ssh-key on Linux for user shekhar and copy it on
Windows machine to make a password less connection.

++++++++++++++++++++++++++++++

shekhar@LinuxBox:~$ ssh-copy-id shekhar@WindowsBox.doamin.com
shekhar@WindowsBox's password:
Now try logging into the machine, with "ssh 'shekhar@WindowsBox.domain.com'",
and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
++++++++++++++++++++++++++++++++


4. Now I run the same script again. Now it doesn't asks a password makes a
connection with Windows box and display Hello world(first line of code) but
fails on the second line

+++++++++++++++

shekhar@LinuxBox:~$ ssh shekhar@WindoxBox.domain.com  'powershell
"C:/scripts/abc.ps1"'
Hello World!
WARNING: Error initializing default drive: 'Unable to contact the server.
This
may be because this server does not exist, it is currently down, or it does
not
 have the Active Directory Web Services running.'.
Get-ADComputer : Unable to contact the server. This may be because this
server
does not exist, it is currently down, or it does not have the Active
Directory
Web Services running.
At C:\scripts\abc.ps1:3 char:15
+ get-adcomputer <<<<  -Filter * |select Name|select -first 10
    + CategoryInfo          : ResourceUnavailable: (:) [Get-ADComputer],
ADSer
   verDownException
    + FullyQualifiedErrorId : Unable to contact the server. This may be
becaus
   e this server does not exist, it is currently down, or it does not have
th
  e Active Directory Web Services running.,Microsoft.ActiveDirectory.Managem
 ent.Commands.GetADComputer
++++++++++++++++++

Thanks in advance.

Regards,
Shekhar

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Issue running PowerShell code on Windows Machine from Linux machine using Cygwin
       [not found]   ` <CAE=7pzwMD3A6cH_=Bduk36RM-RBFuytwkgUZg+03ph6e0_jLpw@mail.gmail.com>
@ 2018-07-30 19:47     ` Marco Atzeri
  2018-07-31 12:53       ` Shekhar Shukla
  0 siblings, 1 reply; 7+ messages in thread
From: Marco Atzeri @ 2018-07-30 19:47 UTC (permalink / raw)
  To: Shekhar Shukla, cygwin

going back on the mailing list.

Am 30.07.2018 um 17:40 schrieb Shekhar Shukla:
> Hi Marco,
> 
> You are absolutely right. In the second case, I do not see Administrator 
> group which is necessary. Why is it behaving so when user id is same in 
> both the cases? Is there any workaround to get it working?

I assume is due to Windows security setting.
No idea about workaround, may be some other can help
solving it.

> Thanks again.
> 
> Regards,
> Shekhar
> 
> On Mon, Jul 30, 2018 at 5:30 PM, Marco Atzeri  wrote:
> 
>     Am 30.07.2018 um 13:20 schrieb Shekhar Shukla:
> 
>            Hi Team,
> 
>         I am having issue while establishing a ssh connection from Linux
>         to Windows
>         machine using Cygwin. My powershell script works when I run it
>         from Linux
>         using ssh connection(Cygwin) to Windows  and manually enter my
>         passowrd.
>         But whn I use public key to authenticate my user(making a
>         password less
>         connection), it fails. Is it a bug with CYgwin?
> 
>     ...
> 
> 
>         Thanks in advance.
> 
>         Regards,
>         Shekhar
> 
> 
>     try executing "id" in both scenarios
> 
>     I guess in the second one you are lacking some
>     administrative groups
> 
>     Regards
>     Marco
> 
> 


---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Issue running PowerShell code on Windows Machine from Linux machine using Cygwin
  2018-07-30 15:53 Issue running PowerShell code on Windows Machine from Linux machine using Cygwin Shekhar Shukla
       [not found] ` <59d985e9-7702-cbdb-8da5-8c825def9064@gmail.com>
@ 2018-07-30 21:47 ` john doe
  2018-07-31  1:13 ` Achim Gratz
  2 siblings, 0 replies; 7+ messages in thread
From: john doe @ 2018-07-30 21:47 UTC (permalink / raw)
  To: cygwin

On 7/30/2018 1:20 PM, Shekhar Shukla wrote:
>   Hi Team,
> 
> I am having issue while establishing a ssh connection from Linux to Windows
> machine using Cygwin. My powershell script works when I run it from Linux
> using ssh connection(Cygwin) to Windows  and manually enter my passowrd.
> But whn I use public key to authenticate my user(making a password less
> connection), it fails. Is it a bug with CYgwin?
> 
> Below is the step by step explantion-
> 
> 
> 1. Sample
> Code
> I have put on Windows machine. This machine has Cygwin installed on it
> 
> +++++++++++++
> :
> +++++++++++
> 
> echo "Hello World!"
> import-module ActiveDirectory
> get-adcomputer -Filter * |select Name|select -first 10
> +++++++++++++++++++++++++
> 
> 
> 2. When I run
> this code
>   from Linux machine using Cygwin WITHOUT enabling password-less connection,
> It asks for password
> of Windows machine and after entering the password it
>   execute
> s
>   like a charm. See below-
> 
> +++++++++++++++++++++++
> 
> shekhar@LinuxBox:~$ ssh shekhar@WindowsBox.doamin.com 'powershell
> "C:/scripts/abc.ps1"'
> shekhar@WindoxBox.domain.com's password:
> 
> Hello World!
> 
> Name
> ----
> Server1
> Server2
> Server3
> Server4
> 
> ++++++++++++++++++++++++
> 
> 3. Now I generate an ssh-key on Linux for user shekhar and copy it on
> Windows machine to make a password less connection.
> 
> ++++++++++++++++++++++++++++++
> 
> shekhar@LinuxBox:~$ ssh-copy-id shekhar@WindowsBox.doamin.com
> shekhar@WindowsBox's password:
> Now try logging into the machine, with "ssh 'shekhar@WindowsBox.domain.com'",
> and check in:
> 
>    .ssh/authorized_keys
> 
> to make sure we haven't added extra keys that you weren't expecting.
> ++++++++++++++++++++++++++++++++
> 
> 
> 4. Now I run the same script again. Now it doesn't asks a password makes a
> connection with Windows box and display Hello world(first line of code) but
> fails on the second line
> 
> +++++++++++++++
> 
> shekhar@LinuxBox:~$ ssh shekhar@WindoxBox.domain.com  'powershell
> "C:/scripts/abc.ps1"'
> Hello World!
> WARNING: Error initializing default drive: 'Unable to contact the server.
> This
> may be because this server does not exist, it is currently down, or it does
> not
>   have the Active Directory Web Services running.'.
> Get-ADComputer : Unable to contact the server. This may be because this
> server
> does not exist, it is currently down, or it does not have the Active
> Directory
> Web Services running.
> At C:\scripts\abc.ps1:3 char:15
> + get-adcomputer <<<<  -Filter * |select Name|select -first 10
>      + CategoryInfo          : ResourceUnavailable: (:) [Get-ADComputer],
> ADSer
>     verDownException
>      + FullyQualifiedErrorId : Unable to contact the server. This may be
> becaus
>     e this server does not exist, it is currently down, or it does not have
> th
>    e Active Directory Web Services running.,Microsoft.ActiveDirectory.Managem
>   ent.Commands.GetADComputer
> ++++++++++++++++++
> 

In ~/.ssh/authorized_keys you could try those options:

NO-PTY,NO-USER-RC ssh

EG: authorized_keys:
NO-PTY,NO-USER-RC ssh ...

https://www.ssh.com/ssh/authorized_keys/openssh

-- 
John Doe

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Issue running PowerShell code on Windows Machine from Linux machine using Cygwin
  2018-07-30 15:53 Issue running PowerShell code on Windows Machine from Linux machine using Cygwin Shekhar Shukla
       [not found] ` <59d985e9-7702-cbdb-8da5-8c825def9064@gmail.com>
  2018-07-30 21:47 ` john doe
@ 2018-07-31  1:13 ` Achim Gratz
  2018-07-31 13:20   ` Thomas Wolff
  2 siblings, 1 reply; 7+ messages in thread
From: Achim Gratz @ 2018-07-31  1:13 UTC (permalink / raw)
  To: cygwin

Shekhar Shukla writes:
> I am having issue while establishing a ssh connection from Linux to Windows
> machine using Cygwin. My powershell script works when I run it from Linux
> using ssh connection(Cygwin) to Windows  and manually enter my passowrd.
> But whn I use public key to authenticate my user(making a password less
> connection), it fails. Is it a bug with CYgwin?

No, Windows simply does not give you full access to your normal
privileges when you log in remotely without a password.  Specifically,
you won't be able to access anything that is considered non-local, like
external fileshares.

See: https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-setuid-overview

If you trust the server in question and all its administrators and other
users, you can use "Method 3" as described above.  Don't forget to set
up cygserver if you want to be able to set or change the password with a
non-administrative account.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for KORG EX-800 and Poly-800MkII V0.9:
http://Synth.Stromeko.net/Downloads.html#KorgSDada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Issue running PowerShell code on Windows Machine from Linux machine using Cygwin
  2018-07-30 19:47     ` Marco Atzeri
@ 2018-07-31 12:53       ` Shekhar Shukla
  0 siblings, 0 replies; 7+ messages in thread
From: Shekhar Shukla @ 2018-07-31 12:53 UTC (permalink / raw)
  To: cygwin

Hello,

I will appreciate any help. Thanks.

On Mon, Jul 30, 2018 at 10:57 PM, Marco Atzeri <marco.atzeri@gmail.com>
wrote:

> going back on the mailing list.
>
> Am 30.07.2018 um 17:40 schrieb Shekhar Shukla:
>
>> Hi Marco,
>>
>> You are absolutely right. In the second case, I do not see Administrator
>> group which is necessary. Why is it behaving so when user id is same in
>> both the cases? Is there any workaround to get it working?
>>
>
> I assume is due to Windows security setting.
> No idea about workaround, may be some other can help
> solving it.
>
> Thanks again.
>>
>> Regards,
>> Shekhar
>>
>> On Mon, Jul 30, 2018 at 5:30 PM, Marco Atzeri  wrote:
>>
>>     Am 30.07.2018 um 13:20 schrieb Shekhar Shukla:
>>
>>            Hi Team,
>>
>>         I am having issue while establishing a ssh connection from Linux
>>         to Windows
>>         machine using Cygwin. My powershell script works when I run it
>>         from Linux
>>         using ssh connection(Cygwin) to Windows  and manually enter my
>>         passowrd.
>>         But whn I use public key to authenticate my user(making a
>>         password less
>>         connection), it fails. Is it a bug with CYgwin?
>>
>>     ...
>>
>>
>>         Thanks in advance.
>>
>>         Regards,
>>         Shekhar
>>
>>
>>     try executing "id" in both scenarios
>>
>>     I guess in the second one you are lacking some
>>     administrative groups
>>
>>     Regards
>>     Marco
>>
>>
>>
>
> ---
> Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
> https://www.avast.com/antivirus
>
>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Issue running PowerShell code on Windows Machine from Linux machine using Cygwin
  2018-07-31  1:13 ` Achim Gratz
@ 2018-07-31 13:20   ` Thomas Wolff
  2018-08-01 18:27     ` Achim Gratz
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Wolff @ 2018-07-31 13:20 UTC (permalink / raw)
  To: cygwin


Am 30.07.2018 um 21:05 schrieb Achim Gratz:
> Shekhar Shukla writes:
>> I am having issue while establishing a ssh connection from Linux to Windows
>> machine using Cygwin. My powershell script works when I run it from Linux
>> using ssh connection(Cygwin) to Windows  and manually enter my passowrd.
>> But whn I use public key to authenticate my user(making a password less
>> connection), it fails. Is it a bug with CYgwin?
> No, Windows simply does not give you full access to your normal
> privileges when you log in remotely without a password.  Specifically,
> you won't be able to access anything that is considered non-local, like
> external fileshares.
If I setup password-less login to the cygwin ssh server, using 
authorized-keys, I can access all remote shares from cygwin,
and also from cmd, started from cygwin with `winpty cmd`, for that matter.
Possibly, if the remote login is the first login of the user, the mounts 
will just have to be established? (Using `net use`)

> See: https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-setuid-overview
>
> If you trust the server in question and all its administrators and other
> users, you can use "Method 3" as described above.  Don't forget to set
> up cygserver if you want to be able to set or change the password with a
> non-administrative account.
>
>
> Regards,
> Achim.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Issue running PowerShell code on Windows Machine from Linux machine using Cygwin
  2018-07-31 13:20   ` Thomas Wolff
@ 2018-08-01 18:27     ` Achim Gratz
  0 siblings, 0 replies; 7+ messages in thread
From: Achim Gratz @ 2018-08-01 18:27 UTC (permalink / raw)
  To: cygwin

Thomas Wolff writes:
> If I setup password-less login to the cygwin ssh server, using
> authorized-keys, I can access all remote shares from cygwin,
> and also from cmd, started from cygwin with `winpty cmd`, for that matter.
> Possibly, if the remote login is the first login of the user, the
> mounts will just have to be established? (Using `net use`)

I know for certain that absolutely doesn't work in a proper AD domain.
If you're in a home network, the rules are much more relaxed, though.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf Blofeld V1.15B11:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-08-01 18:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30 15:53 Issue running PowerShell code on Windows Machine from Linux machine using Cygwin Shekhar Shukla
     [not found] ` <59d985e9-7702-cbdb-8da5-8c825def9064@gmail.com>
     [not found]   ` <CAE=7pzwMD3A6cH_=Bduk36RM-RBFuytwkgUZg+03ph6e0_jLpw@mail.gmail.com>
2018-07-30 19:47     ` Marco Atzeri
2018-07-31 12:53       ` Shekhar Shukla
2018-07-30 21:47 ` john doe
2018-07-31  1:13 ` Achim Gratz
2018-07-31 13:20   ` Thomas Wolff
2018-08-01 18:27     ` Achim Gratz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).