Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::SSH::Perl connection as user

Status
Not open for further replies.

ability1

Programmer
Dec 24, 2002
23
US
We've written a simple script to test ssh login via Net::SSH::perl but we can only get the script to work when being executed as root and not as user.

This is the simple script, any help would be very much appreciated.
Code:
use Net::SSH::Perl;

$host = "my.server.com";
$user = "root";
$passwd = "foo";

my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $passwd);
$ssh->cmd("ls /home/virtual/admin89/var/[URL unfurl="true"]www/cgi-bin/tmp[/URL] > /home/virtual/admin89/var/[URL unfurl="true"]www/cgi-bin/tmp/txt.dat");[/URL]
Thanks again
 
Check the privs for the user, they may not be permitted to login into the shell

--Paul

cigless ...
 
I'm running ensim (not sure if your familiar with it) but ssh is enabled on a user level for this account and we have no issue logging in via ssh through a tradiontal method such as putty.
 
What errors are you getting?
Code:
my $ssh = Net::SSH::Perl->new($host) or die "Cant create new instance of ssh object";
$ssh->login($user, $passwd) or die "Cant login";
$ssh->cmd("ls /home/virtual/admin89/var/[URL unfurl="true"]www/cgi-bin/tmp[/URL] > /home/virtual/admin89/var/[URL unfurl="true"]www/cgi-bin/tmp/txt.dat");[/URL]
--Paul

cigless ...
 
-bash-2.05b$ perl test.pl
Can't locate Net/SSH/Perl.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at test.pl line 28.
BEGIN failed--compilation aborted at test.pl line 28.
 
How did you install Net::SSH::perl?
--Paul

cigless ...
 
I installed it as super user. I am finding that ensim pro isn't allowing virtual users to share the root install of cpan installs.

However I'm not sure of how to install the cpan on the user directory level
 
perl -MCPAN -e shell

have a look at the use lib directive, that allows you to refer to local directories as though they were in the @INC path

--Paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top