Re: [Ssh-sftp-perl-users] Net::SSH::Perl error: Could not dupe: Bad file descriptor
Brought to you by:
dbrobins
|
From: Christian K. <chr...@ci...> - 2009-04-01 23:18:07
|
Ah, I figured it out myself!
use Net::SSH::Perl;
sub ssh_init($$$$) {
my ($username, $ip, $port, $password) = @_;
my $ssh = Net::SSH::Perl->new($ip, (
protocol => '2,1',
port => $port,
debug => 1,
interactive => 0,
));
if(not defined $ssh) {
print STDERR 'Creating SSH object failed';
return undef;
}
$ssh->login($username, $password);
return $ssh;
}
close STDIN;
my $sshHandle = ssh_init('testuser', '127.0.0.1', '22', 'password');
my ($stdout, $stderr, $exit) = $sshHandle->cmd('ls /');
print $stdout;
dies with Bad File Descriptor, but if you comment out the close STDIN; line,
it works fine.
On Wed, 1 Apr 2009 04:25:58 pm Christian King wrote:
> Hi,
>
> Whenever Net::SSH::Perl tries to connect to a server, it gets this error:
> Could not dupe: Bad file descriptor I've tried this with a number of
> servers, and have the same issue every time a successful connection is
> made.
>
> This is a fresh install (with perl -MCPAN -e 'install Net::SSH::Perl') on
> Kubuntu 8.10
>
> Anyone have any ideas? Am I missing some library?
>
> Debug output showing the error:
> devbox: Reading configuration data /home/kingc/.ssh/config
> devbox: Reading configuration data /etc/ssh_config
> devbox: Connecting to 127.0.0.1, port 22.
> devbox: Remote protocol version 2.0, remote software version OpenSSH_5.1p1
> Debian-3ubuntu1
> devbox: Net::SSH::Perl Version 1.34, protocol version 2.0.
> .evbox: No compat match: OpenSSH_5.1p1 Debian-3ubuntu1
> devbox: Connection established.
> devbox: Sent key-exchange init (KEXINIT), wait response.
> devbox: Algorithms, c->s: 3des-cbc hmac-sha1 none
> devbox: Algorithms, s->c: 3des-cbc hmac-sha1 none
> devbox: Entering Diffie-Hellman Group 1 key exchange.
> devbox: Sent DH public key, waiting for reply.
> devbox: Received host key, type 'ssh-dss'.
> devbox: Host '127.0.0.1' is known and matches the host key.
> devbox: Computing shared secret key.
> devbox: Verifying server signature.
> devbox: Waiting for NEWKEYS message.
> devbox: Send NEWKEYS.
> devbox: Enabling encryption/MAC/compression.
> devbox: Sending request for user-authentication service.
> devbox: Service accepted: ssh-userauth.
> devbox: Trying empty user-authentication request.
> devbox: Authentication methods that can continue: publickey,password.
> devbox: Next method to try is publickey.
> devbox: Next method to try is password.
> devbox: Trying password authentication.
> devbox: Login completed, opening dummy shell channel.
> devbox: channel 0: new [client-session]
> devbox: Requesting channel_open for channel 0.
> devbox: channel 0: open confirm rwindow 0 rmax 32768
> devbox: Got channel open confirmation, requesting shell.
> devbox: Requesting service shell on channel 0.
> Could not dupe: Bad file descriptor
--
Christian King
CITEC Security Operations
|