delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/07/03/04:11:14

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Date: Wed, 3 Jul 2002 11:10:37 +0300
From: Ville Herva <vherva AT niksula DOT hut DOT fi>
To: cygwin AT cygwin DOT com
Subject: Re: Expect and ssh
Message-ID: <20020703081037.GH9092@niksula.cs.hut.fi>
References: <3D2228AE DOT B0907091 AT noaa DOT gov>
Mime-Version: 1.0
In-Reply-To: <3D2228AE.B0907091@noaa.gov>
User-Agent: Mutt/1.3.25i

On Tue, Jul 02, 2002 at 06:26:54PM -0400, you [Arthur Taylor] wrote:
> Someone had a similar issue to this in May...  But I didn't see any
> follow up...
> Arthur
> 
> Sample expect script:
> 
> ---------------------
> 
> #! /usr/bin/expect -f
> 
> spawn /usr/bin/ssh <name>@<host>
> expect "password:"
> send "<password>\r"
> expect ">"
> send "ls -l\r"
> expect ">"
> send "exit\r"
> exit

First: Any particular reason you are not using public key authentication?
You just need to 

  ssh-keygen -t dsa
  (store the keys somewhere safe)
  append the pub key to remotehost:~user/.ssh/authorized_keys2

then just

  ssh -i <path to priv key> <name>@<host> "ls -l"

You can use empty passphrases for the keys - that's not less safe than your
expect case - but it's always better to have a passphrase. Also, you can
limit the command allowed for that particular key from the remote end by
specifying the command in remotehost:~user/.ssh/authorized_keys2 after the
key. Then anyone who gets access to that particular private key can only
execute "ls -l" or so.

As for your problem: I imagine your script does not work, because ssh
(I'm looking at openssh-3.4) checks in function readpass.c:read_passphrase()
whether stdin is a TTY (in your case it's not) and then tries to to use
ssh_askpass, /dev/tty etc. Have a look at the code yourself. 

lftp had the same problem in its ssh-code, I'm not sure how they solved it.


-- v --

v AT iki DOT fi

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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