ashok.g has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks,
I'm trying to connect to remote servers using Net::SSH::Expect. Between the servers the SSH keys were distributed.
The connection is always happening as user apache even if we specify a user (existing or not existing)in the connection.
Here is the subroutine I used in connecting to remote host via a CGI script.
sub SSH_Reference { my ($rip,$rusr) = @_; chomp($rip,$rusr); my $ssh = Net::SSH::Expect->new( host => $rip, user => $rusr, timeout => 15, raw_pty => 1 ); eval{ $ssh->run_ssh(); };

When I print $@ it is saying that /var/www/.ssh canno't be created.


Can anyone tell me why this is happening?

Replies are listed 'Best First'.
Re: Net::SSH::Expect login using SSH keys
by moritz (Cardinal) on Dec 07, 2010 at 12:48 UTC
Re: Net::SSH::Expect login using SSH keys
by perl_lover (Chaplain) on Dec 07, 2010 at 12:49 UTC
    You need to show some code to get proper response. Are you passing the user name while creating the Net::SSH::Expect object? Document says you need to pass user name even for public key authentication
    # Note that when you use public-key authentication you won't need to s +et the 'password' constructor attribute # but you still need to define the 'user' attribute.

    use Perl;
    Perl4Everything
      print "$@"; $test = $ssh->read_line(); print "$test";

      Here $test is printing as Could not create directory '/var/www/.ssh'. on my browser.

      I tried with the ncoadmin (a non-root, existing system user). But the same error I'm getting when I tried to run this connection by sending the $rusr as 'blahblah'...

        What effective user is this script running under? Do they have permission to write to /var/www ?

        Net::SSH is just a wrapper around your local ssh command, so could this be an underlying permissions issue?

        Maybe Net::SSH::Perl is an option?

        Edited to correct links 20101207 @ 13:34 - CB