http://www.perlmonks.org?node_id=923531

Only1KW has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to connect to a remote system via the Net::OpenSSH->new module, but the connection keeps failing. I've tried multiple systems with the same result. My simplified script is:

use Net::OpenSSH; my $ssh = Net::OpenSSH->new('username:password@hostname', ssh_cmd => ' +/bin/ssh'); $ssh->error and die "Can't ssh: " . $ssh->error;

My output is always:

muxserver_listen bind(): Not owner Can't ssh: unable to establish master SSH connection: bad password or +master process exited unexpectedly at ~homedir/test.perl line 9.

I've tried assigning the the "ssh_cmd" parameter to every instance of ssh I know of on my system (4) and even not including that parameter, but get the same results every time. I've verified that in every host I tried, my password was correct. Googling "muxserver_listen bind(): Not owner" (in quotes) has literally no hits.

Replies are listed 'Best First'.
Re: Net::OpenSSH connection failing with 'muxserver_listen bind(): Not owner'
by ikegami (Patriarch) on Aug 31, 2011 at 21:44 UTC

    This is just extra info, I don't have an answer.

    Googling "muxserver_listen bind(): Not owner" (in quotes) has literally no hits.

    That's a bit too specific. muxserver_listen is a function of openssl. It's trying to bind a socket to a (specific or arbitrary) port so that it can accept incoming connections. bind, a system call, is returning an error that stringifies to "No Owner".

    It sounds like some kind of permission issue, but I can't find any docs on it. You don't appear to be Linux since it doesn't seem to be able produce that error message:

    $ perl -E'say $!=$_ for 0..65535' | grep -i owner Owner died

    Try finding out under what circumstances your system's bind can return "No owner". Try searching for "owner" in the your system's bind(2) man page.

      No, I'm not running Linux. It's AIX. But I checked the man page and it doesn't define its error return codes, and the word "owner" is nowhere in there.
Re: Net::OpenSSH connection failing with 'muxserver_listen bind(): Not owner'
by salva (Canon) on Sep 01, 2011 at 06:53 UTC
    I guess that ssh is not able to create the unix socket under ~/.libnet-openssh-perl/ because of incorrect file system permissions.

    Anyway, in those cases, truss is the tool that would let you see what's really going wrong. Just ensure you run it with the -f flag to also trace child processes.

      Truss appears to be a very useful tool I was unaware of. I'm seeing multiple instances of the following line from the output, that I'm guessing is the culprit:

      statx("$HOMEDIR/.libnet-openssh-perl/$USERNAME-$REMOTEHOST-78612-88421", 0x000000011000B178, 176, 0) Err#2  ENOENT

      I see no attempt from any system call to actually create the file being referenced. The $HOMEDIR/.libnet-openssh-perl directory is empty. Any idea what may be causing OpenSSH to be looking for this file, and/or what I should be doing to correct it?

        That statx calls are done by the script process, checking for the UNIX domain socket to appear, but in some place there should be another call from the forked ssh process doing a bind call that fails.

        Anyway, what permissions has $HOMEDIR/.libnet-openssh-perl/?

Re: Net::OpenSSH connection failing with 'muxserver_listen bind(): Not owner'
by Only1KW (Sexton) on Sep 08, 2011 at 19:03 UTC
    An update: I got frustrated with getting this working in AIX, and so instead moved to a Linux box (which is a less-optimal environment for me to work in for reasons I won't get into here) and reinstalled a newer version of Perl there. However, Net::OpenSSH ended up failing with almost an identical error! "muxserver_listen bind(): Operation not permitted".

    Since this is a more common error, a Google search turned up more information. It turns out that, as salva guessed earlier, the unix socket could not be created under ~/.libnet-openssh-perl. However, the problem wasn't a permission one but, since my home directory is in AFS, AFS doesn't permit the creation of sockets.

    So I'm now trying the following:

    my $ssh = Net::OpenSSH->new('username@hostname', strict_mode => 0, ctl_dir => "/tmp/.libnet-openssh-perl");

    ...and this works! Of course, I'm running without strict mode, which is supposedly insecure (which I don't understand since if .libnet-openssh-perl prohibits others from writing to the directory, what good forcing all ancestors to also prohibit writing to their directory gains, but I'm not a security expert). But it's either that or not run Net::OpenSSH at all since the AFS directories exist (at least in part) so I don't need to be given write access to anywhere local on the box (besides /tmp, which gives write access to everyone).

      my home directory is in AFS, AFS doesn't permit the creation of sockets

      That well deserves an entry on the troubleshooting guide, thank you for posting it back!

      which I don't understand since if .libnet-openssh-perl prohibits others from writing to the directory, what good forcing all ancestors to also prohibit writing to their directory gains

      For instance, it allows the owner of the upper directory to get Net::OpenSSH placing the mux socket in a file system under its control (for instance a NFS share from other machine where he is root and can change permisions at will), or a specially crafted FUSE-based file system.

      Also, he could replace the mux socket by one under his control. That would allow him to see everything you send to the remote machine.

      Anyway, I prefer to play on the safe side even if that means being a little paranoid!