[Ssh-sftp-perl-users] does LocalForward work?
Brought to you by:
dbrobins
From: <at...@ia...> - 2005-02-03 20:06:52
|
I am trying to use LocalForward. Here is a basic script with my attempt. The local port does not seem to get opened. Can you please let me know how to do this? I didn't see anything in the documents or archives. Thanks, Drew $ cat LocalForward.pl #!/usr/bin/perl -w use Net::SSH::Perl; use Net::Telnet; $connection_time=3D60; # seconds $tunnelhost=3D"someHost"; $localhost=3D"someLocalHost"; $tunnelhost_login=3D"THLogin"; $tunnelhost_pwd=3D"THPass"; $localhost_login=3D"LHLogin"; $localhost_pwd=3D"LHPass"; $localhost_prompt=3D"/[\\#\\\$] \$/"; $local_port=3D9999; my $ssh =3D Net::SSH::Perl->new($tunnelhost, debug =3D> "yes", options =3D> [ "LocalForward $local_port $localhost:23" ]); $ssh->login($tunnelhost_login,$tunnelhost_pwd); $pid=3Dfork; if (!$pid) { my($stdout, $stderr, $exit) =3D $ssh->cmd("sleep $connection_time"); # my($stdout, $stderr, $exit) =3D $ssh->cmd("who"); # print $stdout; } else { sleep(1); my $tel =3D new Net::Telnet (Port =3D> $local_port, Timeout =3D> 30, Prompt =3D> $localhost_prompt); $tel->open("localhost"); $tel->login($localhost_login,$localhost_pwd); @lines=3D$tel->cmd("who"); print @lines; } exit(0); $ ./LocalForward.pl currentHost: Reading configuration data /home/user/.ssh/config currentHost: Reading configuration data /etc/ssh_config currentHost: Connecting to someHost, port 22. currentHost: Remote protocol version 2.0, remote software version OpenSSH_3.1p1 currentHost: Net::SSH::Perl Version 1.26, protocol version 2.0. currentHost: No compat match: OpenSSH_3.1p1. currentHost: Connection established. currentHost: Sent key-exchange init (KEXINIT), wait response. currentHost: Algorithms, c->s: 3des-cbc hmac-sha1 none currentHost: Algorithms, s->c: 3des-cbc hmac-sha1 none currentHost: Entering Diffie-Hellman Group 1 key exchange. currentHost: Sent DH public key, waiting for reply. currentHost: Received host key, type 'ssh-dss'. currentHost: Host 'someHost' is known and matches the host key. currentHost: Computing shared secret key. currentHost: Verifying server signature. currentHost: Waiting for NEWKEYS message. currentHost: Enabling incoming encryption/MAC/compression. currentHost: Send NEWKEYS, enable outgoing encryption/MAC/compression. currentHost: Sending request for user-authentication service. currentHost: Service accepted: ssh-userauth. currentHost: Trying empty user-authentication request. currentHost: Authentication methods that can continue: publickey,password,keyboard-interactive. currentHost: Next method to try is publickey. currentHost: Next method to try is password. currentHost: Trying password authentication. currentHost: Login completed, opening dummy shell channel. currentHost: channel 0: new [client-session] currentHost: Requesting channel_open for channel 0. currentHost: channel 0: open confirm rwindow 0 rmax 32768 currentHost: Got channel open confirmation, requesting shell. currentHost: Requesting service shell on channel 0. currentHost: channel 1: new [client-session] currentHost: Requesting channel_open for channel 1. currentHost: Entering interactive session. currentHost: Sending command: sleep 60 currentHost: Requesting service exec on channel 1. currentHost: channel 1: open confirm rwindow 0 rmax 32768 problem connecting to "localhost", port 9999: Connection refused at ./LocalForward.pl line 33 |