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

I have a machine on my LAN called "rocky" that's running Rocky Linux 8.5. My user id on it is also "rocky" and I've set up the appropriate ~/.ssh/config magic on my laptop to pass the username and key path to ssh so that ssh rocky whoami outputs rocky. I don't get prompted for a passphrase for the key because I've already ssh-add'ed it to my local ssh-agent.

My laptop is running Windows 10 with Ubuntu 20.03.4 LTS in a WSL1 container. The libnet-openssh-perl package is installed and gives me Net::OpenSSH version 0.78, but I've also tried sudo cpanm --install Net::OpenSSH to get version 0.80 and it doesn't fix the problem, which is this: when I run the following Perl program I get the error:-

channel_post_mux_listener getpeereid failed: Operation not supported Use of uninitialized value $_[0] in join or string at /usr/share/perl5 +/Net/OpenSSH.pm line 122. Can't ssh to rocky: unable to establish master SSH connection: at Jun +k/snaggle.pl line 17.

Actually 0.80 gets rid of the "uninitialized value" error, but I still get the "getpeerid" problem. Any suggestions? Here's the script:-

#!/usr/bin/perl use strict; use warnings; use Net::OpenSSH; use constant { HOST => q{rocky}, USER => q{rocky}, KEYPATH => q{~/.ssh/broadey.net_rsa}, CMD => q{whoami}, }; #my $ssh = Net::OpenSSH->new(HOST); my $ssh = Net::OpenSSH->new(HOST, user=>USER, key_path=>KEYPATH); $ssh->error and die "Can't ssh to ${\HOST}: " . $ssh->error; my ($out,$pid) = $ssh->pipe_out(CMD) or die "Remote command failed: " . $ssh->error; local $| = 1; # enable output autoflush while (<$out>) { print time, ": ", $_; # $_ includes the \n }
As you can see from the commented out code, I originally tried passing just the hostname and relying on ~/.ssh/config, but then tried passing the username and key_path to see if it made any difference. It didn't. Thanks for your help!
  • Comment on Net::OpenSSH channel_post_mux_listener getpeereid failed: Operation not supported [RESOLVED]
  • Select or Download Code

Replies are listed 'Best First'.
Re: Net::OpenSSH channel_post_mux_listener getpeereid failed: Operation not supported
by Corion (Patriarch) on Feb 15, 2022 at 08:38 UTC

    While I can't pinpoint anything specific, you can find out more about where exactly things go sideways by enabling debugging in Net::OpenSSH:

    $Net::OpenSSH::debug = ~0;

    turns on all debug information, but I think you'll be most interested in what the documentation calls bit 4 ("connecting") and bit 64 ("IO loop"). I would call these bits "bit 3" and "bit 7", but having them as numbers suggests the following line:

    $Net::OpenSSH::debug = 4+64; # connection and IO loop

    A random Google search for the error message and WSL suggests that maybe WSL doesn't allow fetching the peer user information, or maybe that the wrong SSH command (maybe ssh.exe ?) gets launched. This feels like a really long shot but should be easily verified (or rather, discarded) if you look at the output of

    $Net::OpenSSH::debug = 8+16; # commands and execution

      The debug did the trick, thanks!

      I set it to ~0 to get EVERYTHING and noticed the ctl_dir and ctl_path values were pointing into my home directory, which on WSL1 is /mnt/c/Users/kevinb - a drvfs mount of my Windows C: drive. I remembered TROUBLESHOOTING 6 in the POD page saying Some file systems (as for instance FAT or AFS) do not support placing sockets inside them and guessed that maybe NTFS was on the Naughty List as well.

      I created a /tmp/kevinb directory (which df tells me is rootfs), chmod'ed it to 0700 for good measure and added ctl_dir=>"/tmp/kevinb" to the Net::OpenSSH->new constructor call. Hey, presto - the getpeerid not supported error went away and my script started working.

      Thanks for pointing me in the right direction!

        Hahaha... You know, I added the troubleshooting section to the module documentation in 2009, thirteen years ago and, as far as I can remember, this is the first time I have heard of somebody that had read it or/and found it useful!

        You made my day :-)