From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94681 invoked by alias); 30 Jul 2018 17:31:03 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 94661 invoked by uid 89); 30 Jul 2018 17:31:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*F:D*mail.com, H*Ad:D*mail.com, Shukla, shukla X-HELO: mout.gmx.com Received: from mout.gmx.com (HELO mout.gmx.com) (74.208.4.200) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Jul 2018 17:31:01 +0000 Received: from johndoe65534.mail.com ([85.28.70.154]) by mail.gmx.com (mrgmxus001 [74.208.5.15]) with ESMTPSA (Nemesis) id 0MQ2nF-1feywM2dhT-005MNH for ; Mon, 30 Jul 2018 19:30:58 +0200 Subject: Re: Issue running PowerShell code on Windows Machine from Linux machine using Cygwin To: cygwin@cygwin.com References: From: john doe Message-ID: Date: Mon, 30 Jul 2018 21:47:00 -0000 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00286.txt.bz2 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