Subject: | IPv6 addresses shouldn't be squared |
ENV:
perl -v
This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
Ubuntu 10.04.4
Net::OpenSSH 0.57
DESC:
I'm trying to connect to a host via IPv6 according to the manual:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Net::OpenSSH;
$| = 1;
my $ip = '2002:5bcc:18fd:c:xxx';
my $ssh = Net::OpenSSH->new('root@'.$ip); # IPv6
$ssh->error and die "Couldn't establish SSH connection: ". $ssh->error;
ssh: Could not resolve hostname [2002:5bcc:18fd:c:xxx]: Name or service
not known
Couldn't establish SSH connection: unable to establish master SSH
connection: master process exited unexpectedly
This is because openssh recognizes ipv6 addresses in squares as
hostnames and tries to resolve them. Probably it's a openssh bug:
ssh root@2002:5bcc:18fd:c:xxx "pwd" # works
ssh root@[2002:5bcc:18fd:c:xxx] "pwd" # doesn't
Net::OpenSSH shouldn't put ipv6 hosts in squares in (at least until it's
fixed in openssh):
if (defined $ipv6) {
($host) = $ipv6 =~ /^\[?(.*?)\]?$/;
$host_squared = "[$host]";
}
else {
$host_squared = $host;
}