X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=Zmu5BgJ6CuSQY8D5 c/rWWMAPpIQmS3GsfaeGa11V0/rrJBvmQXGLinOyw0YhA/hjcJvpVoOWBEenv6hI Ia13yzbXbJSLfBIgqhT1lwC9vS2rkAfS8U1TgcxFVWAlzKN+tcp+3ye26Ka6Bf8l pTPmUkpBwPbtEj0fU1lPwrLNRLU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=WCQT5n1abUY4HI4GBuGe8U KsyyU=; b=YrSjPqlvt4c588RXBHD3m4iPG73cZvzUGIpQlYsxWlBMBS3mWHgU9N VJkVmiJSKNQUvImQFVcgU64zxb+iI0hdv6uEb3X7BL2NZ4sdntc5eu9f4U7LAgu8 KvgpQnUNLgM1+ps+je5GPvGvmPmFqHMgm88S6DlDiudNHC1ZkL+q8= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 Subject: Re: Issue running PowerShell code on Windows Machine from Linux machine using Cygwin To: cygwin AT cygwin DOT com References: From: john doe Message-ID: Date: Mon, 30 Jul 2018 19:30:53 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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 AT LinuxBox:~$ ssh shekhar AT WindowsBox DOT doamin DOT com 'powershell > "C:/scripts/abc.ps1"' > shekhar AT WindoxBox DOT domain DOT 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 AT LinuxBox:~$ ssh-copy-id shekhar AT WindowsBox DOT doamin DOT com > shekhar AT WindowsBox's password: > Now try logging into the machine, with "ssh 'shekhar AT WindowsBox DOT domain DOT 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 AT LinuxBox:~$ ssh shekhar AT WindoxBox DOT domain DOT 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