delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/10/20/13:44:10

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <4176A4F5.BE246208@dessent.net>
Date: Wed, 20 Oct 2004 10:48:37 -0700
From: Brian Dessent <brian AT dessent DOT net>
Organization: My own little world...
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: ssh expect on Cygwin
References: <ffec403e0410192007589447dc AT mail DOT gmail DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com

anurag shukla wrote:

> Hi,
> I just got your mail id from the Cygwin MAiling list.

You're posting to the list, not sending email to any specific person. 
Most people who post on the list do not want to receive email with
questions.  That's what the list is for.

> I am having a tyical problem with expect.
> This is the code fragment that is giving me the problem. May be you
> can help me with this conundrum
> #!/usr/bin/expect
>    spawn ssh -l $user $box_ip
> 
>    while {1} {
>        expect {
>            -exact "$user@$box_ip's password: " {
>              send -- "$passwd\n"
>              break;
>            }
> 
> The problem is every time I run the script, it asks me for the
> password, though it should not. Also, when prompted for password, when
> I enter the password, it just does not accepts it.
> I am running Cygwin on WIndows XP.

I believe that ssh tries to read the passphrase directly from the
terminal from which it was started, rather than reading stdin.  This
allows it to ask for a password even if stdin has been redirected, as in
the case of running a remote command with input.  So, you can't feed it
a password like that with expect.

But, seeing someone try to feed ssh a password with expect will make
most people cringe because "that's not the right way to do it."  You
should instead use public key authentication which allows for secure and
passwordless authentication to the remote system.  All you need to do is
generate a key (run ssh-host-config on the local Cygwin system) and then
place the public half of the key (id_rsa.pub if you chose RSA) in
~/.ssh/authorized_keys on the remote.  Read "man ssh" and "man
ssh_config" for details.

If you *really* must feed ssh a password (despite completely missing the
entire reason for having public key authentication) then look at the
SSH_ASKPASS variable which is documented in the manpage.

Brian

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019