SSH via Expect disconnects

From: Robert Denton (google1_at_headsprout.com)
Date: 02/26/04


Date: 26 Feb 2004 10:36:10 -0800

Hello all,

I am using an expect script to initiate an SSH session to another host
as such:

#! /usr/bin/expect -f

spawn /usr/bin/ssh -R 3214:localhost:22 host.domain.tld
expect -re "word:"
send "<password>\r"
expect eof

This works just fine, or seems to. Then, when on the other host, I
issue the following command to pick-up that ssh session locally, I am
prompted for the password, I enter it, and then the session
disconnects, with the error: connection closed by 127.0.0.1. Here is
the command used:

ssh -p 3214 localhost

Here's the kicker: if I remove Expect from the equation, and just do
it all manually, the disconnect doesn't occur. Are there any Expect
experts out there who can offer a suggestion?

Thanks, Robert.



Relevant Pages

  • Re: SSH via Expect disconnects
    ... I have received one suggestion that I explore the idea of using keys ... > I am using an expect script to initiate an SSH session to another host ... > issue the following command to pick-up that ssh session locally, ... > disconnects, with the error: ...
    (comp.lang.tcl)
  • Re: What does scp2 a ... b mean?
    ... destination within one ssh session with only one authentication. ... multiple files on the same remote host. ... you cannot rename the files on the host machine at ...
    (comp.security.ssh)
  • Re: What does scp2 a ... b mean?
    ... common hierarchy that -r could fetch) from one host to one destination ... within one ssh session with only one authentication. ... I was hoping there was a way to tell scp to use one session for multiple ... files on the same remote host. ...
    (comp.security.ssh)
  • Re: expect THISWILLBENEVERPRINTED the only way to clear the buffer?
    ... > you open a different SSH session for each process? ... Or do you spawn one ... > ssh session and launch these two applications using the same session? ... First application is run on a remote host, second one on the "current" host. ...
    (comp.lang.tcl)
  • sftp w/o ssh
    ... I want to give users possibility to SFTP files to a host from ... outside local network, but I don't want them to establish SSH session to ... provided they both (SSH and SFTP) ...
    (comp.unix.solaris)