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:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=wQz7W/5w9IMr7Fh6e7DnmmEhKnXuw +s1ZQYWJ7WTDvgt3aiMOdMP0OnMztD1PZCavL/60SwkCfNSSjDTeyTdTw1+IhXUV H+PFW7mVBOgw6nfI1EpzMTtfmWVGdv8K7lVtHtuo4549gyUT+K4jUYc0qc+zt/Xj Ib86A9sASv+EXg= 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:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=SG/653s1YPe8Qy2WiSVqsnAlWfk=; b=kzu bUlrMEQ/DoR0uMbh8/vcTl9DhiBsIvpqfSMQrzTAwBqUdJ2sYk5o9wdD4WVIthlu 07YAOPD/6iAqCNTEuYR9kBYURukptjtX0I4Q5c7UPKPQzF0sYFW70cHCqurFnsGU IFiACorNHV8oa7XKjwVj+3z2utZr/qFaeJMie57o= 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.6 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Team, password, establishing, sk:resourc X-HELO: mail-io0-f175.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=rpYPnebdNbCsKewz0Ki8HUDqaoa6R17xd5tabFR7x/Y=; b=GaYBjfgvjkaAbk4+8dMkz4qt1D2hDL+Qez0wL4fm7/6su9F8pKGC8TDgou5phrOIkS UtcnX+C0yyE8994HNTt3Vkqejby71Flok+9w8ukkS/Py8PK7p3XKlK/lF4QmGmM/Ww0I bsrezhl+oETZuN/YB64IF6Ej7QPeRSjaeQE0QL+fa3r5EY8fyHKKhNyBq714kX8+1M8m 3whZatvPGzPRP3LnVfRf2K+e8wOa0QnJN2DqinR4uBDfgaU3iWdXkKJuCUOdQzJhHAmA ZC0P79AbSLriWLspXZFdHGSIpKw6g/Whtrc7p9aIEJ9TMQoUp9241D0U+1BJTsqwLY0l bK3w== MIME-Version: 1.0 From: Shekhar Shukla Date: Mon, 30 Jul 2018 16:50:39 +0530 Message-ID: Subject: Issue running PowerShell code on Windows Machine from Linux machine using Cygwin To: cygwin AT cygwin DOT com Content-Type: text/plain; charset="UTF-8" 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 ++++++++++++++++++ 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