Subject: | socksify SOCKS proxy support |
When I connect directly to an ssh server using an ssh_cmd like
'/usr/bin/ssh', it works.
When I connect via a SOCKS proxy using socksify with an ssh_cmd like
'/usr/local/bin/socksify /usr/bin/ssh' then I get a _conn_lost on the
first read from child.
Attached
1) ssh_problem.txt shows debug tracing with/without use of socksify
wrapper for ssh to use SOCKS proxy
2) proxy.t unit test
run 'perl proxy.t' uses proxy, shows fail
run 'NO_TEST=1 perl proxy.t' goes direct, shows success
Subject: | ssh_problem.txt |
1. direct connection succeeds
#20508 1260200381.00000 new: ssh cmd: /usr/bin/ssh -l devpublish -v wsnmas00 -s sftp
#20508 1260200381.00000 _queue_msg: queueing msg len: 5, code:1, id:3 ... [1]
00 00 00 05 01 00 00 00 03 | .........
#20508 1260200381.00000 _get_msg: waiting for message... [1]
#20508 1260200381.00000 _do_io_unix: _do_io connected: 1
#20508 1260200381.00000 _do_io_unix: _do_io select(-,-,-, undef)
#20508 1260200381.00000 _do_io_unix: _do_io write queue: 9, syswrite: 9, max: 65536
00 00 00 05 01 00 00 00 03 | .........
#20508 1260200381.00000 _do_io_unix: _do_io select(-,-,-, undef)
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
debug1: Reading configuration data /home/edwarp11/.ssh/config
...
#20508 1260200388.00000 _do_io_unix: _do_io read sysread: 9, total read: 9
00 00 00 05 02 00 00 00 03 | .........
#20508 1260200388.00000 _get_msg: got it!, len:5, code:2, id:-, status: -
02 00 00 00 03 | .....
2. socksified connection fails
#20744 1260200403.00000 new: ssh cmd: /home/edwarp11/local/bin/socksify /usr/bin/ssh -l devpublish -v wsnmas00 -s sftp
#20744 1260200403.00000 _queue_msg: queueing msg len: 5, code:1, id:3 ... [1]
00 00 00 05 01 00 00 00 03 | .........
#20744 1260200403.00000 _get_msg: waiting for message... [1]
#20744 1260200403.00000 _do_io_unix: _do_io connected: 1
#20744 1260200403.00000 _do_io_unix: _do_io select(-,-,-, undef)
#20744 1260200403.00000 _do_io_unix: _do_io write queue: 9, syswrite: undef, max: 65536
#20744 1260200403.00000 _conn_lost: _conn_lost
#20744 1260200403.00000 _set_status: _set_status code: 7, str: Connection lost
#20744 1260200403.00000 _set_error: _set_err code: 37, str: Connection to remote server is broken
#20744 1260200403.00000 _conn_lost: _conn_lost
Unable to stablish SFTP connection: Connection to remote server is broken at basic_sftp.t line 52.
#20744 1260200403.00000 DESTROY: Net::SFTP::Foreign=HASH(0x943b0dc)->DESTROY called (current pid: 20744, disconnect_by_pid: )
#20744 1260200403.00000 disconnect: Net::SFTP::Foreign=HASH(0x943b0dc)->disconnect called (ssh pid: 20748)
#20744 1260200403.00000 _conn_lost: _conn_lost
Subject: | proxy.t |
#!/usr/bin/perl
# test Net::SFTP::Foreign via SOCKS proxy
# author peter@dragonstaff.co.uk
use strict;
use warnings;
use Test::More tests => 2;
use File::Which;
my $SOCKSIFY = which('socksify')
or die 'cannot find "socksify" program';
my $SSH = which('ssh')
or die 'cannot find "ssh" program';
my $ssh_cmd;
if ( $ENV{NO_PROXY} ) {
$ssh_cmd = $SSH;
}
else {
$ssh_cmd = $SOCKSIFY . ' ' . $SSH;
}
my $host = 'somehost.com';
my $user = 'someuser';
my $pass = 'somepassword';
my ($sftp, $cwd);
diag "trying to connect";
my %args = (
host => $host,
user => $user,
#password => $pass, # hangs if set and no password required - maybe fixed in Net::SFTP::Foreign version 1.56_03
more => '-v',
ssh_cmd => $ssh_cmd,
);
use_ok('Net::SFTP::Foreign');
{ no warnings 'once'; $Net::SFTP::Foreign::debug = 0xffff; }
$sftp = Net::SFTP::Foreign->new( %args );
$sftp->error and
die "Unable to stablish SFTP connection: " . $sftp->error;
my $msg = "connected to $user\@$host";
$msg .= " via SOCKS proxy" unless $ENV{NO_PROXY};
diag $msg;
$cwd = $sftp->cwd;
diag "cwd: $cwd";
ok( $cwd, 'cwd' );