LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-02-2011, 12:48 PM   #1
verWire3619
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Rep: Reputation: Disabled
Another one . . . . telnet: connect to address 127.0.0.1: Connection refused


CentOS release 5.5 (Final)

I'm not new to linux, but very new to networking. I apologize. I'm sure there's prob an answer, but I'm not sure what I'm looking at.

I have this expect script:
Code:
#!/usr/bin/expect -f

exp_internal 1

set stp [lindex $argv 0]
set logfile [lindex $argv 1]

set timeout 1800
spawn /usr/local/bin/$stp
match_max 100000
expect -exact "Trying"
expect -exact "Connected to"
expect -exact "Escape character is '^\]'.\r\r
"
expect -exact "Select a terminal from the list below:"
sleep 2
send -- "23\r"
expect -exact "Connection established as terminal"
sleep 2
send -- "login:uid=userid\r"
expect -exact "Enter Password :"
send -- "passwd\r"
expect -exact "User logged in on terminal"
expect -exact ";\r"
sleep 2
log_file -noappend $logfile
send -- "rtrv-slk\r"
expect -exact "Command Accepted"
expect -exact "SLK table is"
expect -exact ";\r"
log_file
sleep 2
send -- "logout\r"
expect -exact "Command Completed."

send -- ""
expect -exact "\r
telnet> "
send -- "close\r"
expect eof
/usr/local/bin/$stp looks like this
Code:
#!/bin/bash

FLOOR=1024

lport=0   #initialize
while [ "$lport" -le $FLOOR ]
do
  lport=$RANDOM
done
echo "Generating random local port ---  $lport"
echo "IMPORTANT:  Use Ctrl-] , close to exit"
echo

/usr/bin/ssh -f -N -L $lport:127.0.0.1:23 ncstp
sleep 1
/usr/bin/telnet localhost $lport
I turned diagnostic tracking on in the expect script and got:
Quote:
spawn /usr/local/bin/gotostpnc
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {13443}

expect: does "" (spawn_id exp6) match exact string "Trying"? no
Generating random local port --- 28154

expect: does "Generating random local port --- 28154\r\n" (spawn_id exp6) match exact string "Trying"? no
IMPORTANT: Use Ctrl-] , close to exit


expect: does "Generating random local port --- 28154\r\nIMPORTANT: Use Ctrl-] , close to exit\r\n\r\n" (spawn_id exp6) match exact string "Trying"? no
ssh_exchange_identification: Connection closed by remote host

expect: does "Generating random local port --- 28154\r\nIMPORTANT: Use Ctrl-] , close to exit\r\n\r\nssh_exchange_identification: Connection closed by remote host\r\r\n" (spawn_id exp6) match exact string "Trying"? no
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

expect: does "Generating random local port --- 28154\r\nIMPORTANT: Use Ctrl-] , close to exit\r\n\r\nssh_exchange_identification: Connection closed by remote host\r\r\nTrying 127.0.0.1...\r\r\ntelnet: connect to address 127.0.0.1: Connection refused\r\n" (spawn_id exp6) match exact string "Trying"? yes
expect: set expect_out(0,string) "Trying"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "Generating random local port --- 28154\r\nIMPORTANT: Use Ctrl-] , close to exit\r\n\r\nssh_exchange_identification: Connection closed by remote host\r\r\nTrying"

expect: does " 127.0.0.1...\r\r\ntelnet: connect to address 127.0.0.1: Connection refused\r\n" (spawn_id exp6) match exact string "Connected to"? no
expect: read eof
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " 127.0.0.1...\r\r\ntelnet: connect to address 127.0.0.1: Connection refused\r\n"
expect: spawn id exp6 not open
while executing
"expect -exact "Escape character is '^\]'.\r\r
""
(file "/home/ss7/bin/links.exp" line 13)
This expect script is in a loop in a perl script for 4 network elements. I'm able to make connection to 2 of the 4 elements. This was working at one time.

I do not know what changed.
I'm not sure where to begin to troubleshoot.

Any guidance is much appreciated.

Thanks!
 
Old 09-02-2011, 01:14 PM   #2
thesnow
Member
 
Registered: Nov 2010
Location: Minneapolis, MN
Distribution: Ubuntu, Red Hat, Mint
Posts: 172

Rep: Reputation: 56
Your ssh connection is failing, I'd start by troubleshooting an ssh connection straight to one of the machines you're having issues with and increase ssh verbosity (-vvv). If you Google for your error message, "ssh_exchange_identification: Connection closed by remote host", you may find other insight.
 
1 members found this post helpful.
Old 09-02-2011, 01:49 PM   #3
verWire3619
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you!

So I ran the following 2 commands:

Quote:
% /usr/bin/ssh -v -f -N -L 28154:127.0.0.1:23 ncstp
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to ncstp [10.48.8.16] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: loaded 3 keys
ssh_exchange_identification: Connection closed by remote host
Quote:
% /usr/bin/ssh -v -f -N -L 28154:127.0.0.1:23 nestp
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to nestp [10.48.12.16] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version TF1-SSH-VX-2.0.0-i005
debug1: no match: TF1-SSH-VX-2.0.0-i005
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'nestp' is known and matches the DSA host key.
debug1: Found key in /root/.ssh/known_hosts:57
debug1: ssh_dss_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentication succeeded (none).
debug1: Local connections to LOCALHOST:28154 forwarded to remote address 127.0.0.1:23
debug1: Local forwarding listening on 127.0.0.1 port 28154.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on ::1 port 28154.
debug1: channel 1: new [port listener]
debug1: Entering interactive session.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rndc: connect failed: 127.0.0.1#953: connection refused milindras Linux - Server 41 08-20-2013 05:33 AM
lpr: can't connect to remote host (127.0.0.1): Connection refused linuxboy2008 Linux - Software 2 03-27-2011 03:34 AM
Could not connect to host 127.0.0.1 - connection refused adrian2009 Slackware 1 12-07-2010 06:53 AM
telnet:connect to address 127.0.0.1: connection refused sdeven Linux - Networking 6 12-23-2002 12:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration