Re: Net::SSH2 Question - again-
by Khen1950fx (Canon) on May 28, 2008 at 14:43 UTC
|
| [reply] |
Re: Net::SSH2 Question - again-
by moritz (Cardinal) on May 28, 2008 at 11:00 UTC
|
If you want use a shell through a ssh connection, why use perl at all? ssh does it just fine.
Usually you use perl for this sort of thing if you want to automate something, in which case you don't need a shell. | [reply] |
Re: Net::SSH2 Question - again-
by bgi (Sexton) on May 28, 2008 at 11:06 UTC
|
Sorry, i forgot the half...this is my script so far:
use strict;
use Net::SSH2;
my $ssh1= Net::SSH2-> new();
my $buf;
$ssh1-> connect('ipaddress')
or die "conncet to SSH1 failed";
$ssh1-> auth_password('user', 'pass')
or die "auth1 failed";
my $chan1= $ssh1-> channel();
$chan1-> blocking(1);
$chan1-> exec('uname');
$chan1-> read($buf, 100);
print $buf, "\n";
$chan1-> close;
Works fine -so far-. Now i need to establish the connection from the first SSH-server to the second...
The best will be to manage that with the commands i would give to my putty session...so the next would be "ssh- l user ipaddress" an the there is a password oO
No idea how to manage the password through the channel!!!!
| [reply] [d/l] |
|
|
avoid the issue with a public key
| [reply] |
Re: Net::SSH2 Question - again-
by idsfa (Vicar) on May 28, 2008 at 15:27 UTC
|
use strict;
use Net::SSH2;
my $ssh1 = Net::SSH2->new();
$ssh1->connect($host1) or die "connect to SSH1 failed";
$ssh1->auth_password('user', 'pass') or die "auth1 failed";
$ssh1->tcpip($host2, 22, '127.0.0.1', 9922);
my $ssh2 = Net::SSH2->new();
$ssh2->connect('127.0.0.1', 9922) or die "connect to SSH2 failed";
$ssh2->auth_password('user2', 'pass2') or die "auth2 failed";
# ... as many hops as you need ...
The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon
| [reply] [d/l] |
|
|
Its not working for me...after a few tests i can say, that it dont understand what to do with this line:
$ssh2->connect('127.0.0.1', 9922) or die "connect to SSH2 failed";
| [reply] [d/l] |
|
|
this line is not working!! no idea why...i tested the other lines with if(-command-){print "ok";} and every line prints its "ok" expect the given line with tcpip
| [reply] [d/l] [select] |
Re: Net::SSH2 Question - again-
by bgi (Sexton) on May 28, 2008 at 12:34 UTC
|
No chance, i have no access to the server...
it must be possible to connect to the first SSH Server and then to the second one?!?!
first with username & password
and second only with password but with ssh-option "-l"
| [reply] |
|
|
You can't ssh to it with username and password?!?!?!
| [reply] |
Re: Net::SSH2 Question - again-
by bgi (Sexton) on May 29, 2008 at 07:43 UTC
|
Hello
I have now port of the second server
| [reply] |
Re: Net::SSH2 Question - again-
by bgi (Sexton) on May 31, 2008 at 12:51 UTC
|
Yesterday after i decided to stop trying around i tried the tunnel-issue with the command line tool plink (from putty) aaaaand then, just for fun, i started the script again and IT WORKED!!!!!! so i can definitely say, that there is something wrond with those tcpip-method...
all google-user: hf and good luck | [reply] |
Re: Net::SSH2 Question - again-
by bgi (Sexton) on May 29, 2008 at 08:38 UTC
|
ok, forget my last post *cough*
thank for your help, guys, i will try idsfa 's suggestion first.
Aaaaand i have direct a qustion concerning this:
The authentication to the second server looks like this:
i type "ssh -l username hostname" to the fisrt server's shell and then a field appears: "Password:"
I type my password and i am in...
How can i transfer this authentication-procedure in my script?? The problem is the "-l" option! | [reply] |