ssh-sftp-perl-users Mailing List for Net::SSH and Net::SFTP - Perl modules (Page 13)
Brought to you by:
dbrobins
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(4) |
Feb
(15) |
Mar
(13) |
Apr
(8) |
May
(5) |
Jun
(21) |
Jul
(4) |
Aug
(9) |
Sep
(11) |
Oct
(14) |
Nov
(15) |
Dec
(24) |
2005 |
Jan
(10) |
Feb
(20) |
Mar
(16) |
Apr
(10) |
May
(12) |
Jun
(16) |
Jul
(18) |
Aug
(21) |
Sep
(11) |
Oct
(19) |
Nov
(16) |
Dec
(9) |
2006 |
Jan
(17) |
Feb
(32) |
Mar
(60) |
Apr
(21) |
May
(24) |
Jun
(1) |
Jul
(6) |
Aug
(18) |
Sep
(4) |
Oct
(9) |
Nov
(31) |
Dec
(10) |
2007 |
Jan
(8) |
Feb
(11) |
Mar
(3) |
Apr
(7) |
May
(4) |
Jun
(6) |
Jul
(7) |
Aug
(3) |
Sep
(2) |
Oct
(5) |
Nov
(5) |
Dec
(5) |
2008 |
Jan
(12) |
Feb
(5) |
Mar
(7) |
Apr
(4) |
May
(37) |
Jun
(9) |
Jul
(24) |
Aug
(5) |
Sep
(2) |
Oct
(7) |
Nov
(6) |
Dec
(7) |
2009 |
Jan
(18) |
Feb
(9) |
Mar
(14) |
Apr
(14) |
May
(1) |
Jun
(14) |
Jul
(4) |
Aug
(6) |
Sep
(4) |
Oct
(12) |
Nov
(4) |
Dec
|
2010 |
Jan
|
Feb
(3) |
Mar
|
Apr
(1) |
May
(4) |
Jun
|
Jul
(6) |
Aug
(6) |
Sep
|
Oct
(7) |
Nov
(2) |
Dec
(5) |
2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
(1) |
May
(8) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
|
Oct
(4) |
Nov
(9) |
Dec
(7) |
2012 |
Jan
(1) |
Feb
(19) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
(5) |
Jul
(3) |
Aug
(1) |
Sep
|
Oct
|
Nov
(6) |
Dec
|
2014 |
Jan
(7) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ibrahim S. <sal...@gm...> - 2008-05-14 21:07:53
|
1-how to write gz file into an array. 2- how to write elements in an array without to delete it s contents thanks in advance |
From: Didier D. <ddi...@am...> - 2008-05-14 17:04:14
|
I will be out of the office starting 12/05/2008 and will not return until 26/05/2008. I will respond to your message when I return. |
From: Merijn B. <me...@il...> - 2008-05-14 14:13:21
|
Quoting Ibrahim Salloum (sal...@gm...): > i just wanted to export export LD_LIBRARY_PATH=/usr/local/lib within my > perl script. > You cannot do that. The loader does not take hints from LD_LIBRARY_PATH or LD_PRELOAD in the same process. You can make a springboard shell script, set the variable in there, then call your perl script. Or recompile, as said before. Cheers, -- Merijn Broeren | We take risks, we know we take them. Therefore, when things | come out against us, we have no cause for complaint. | - Scott, last journal entry, march 1912 |
From: Ibrahim S. <sal...@gm...> - 2008-05-14 14:08:30
|
i just wanted to export export LD_LIBRARY_PATH=/usr/local/lib within my perl script. any ideaa thanks in advance |
From: Heiko J. <ja...@hb...> - 2008-05-14 10:37:22
|
Am Dienstag, den 13.05.2008, 13:52 -0400 schrieb Ibrahim Salloum: > export LD_LIBRARY_PATH=/usr/local/lib > > > i put this command using linux to run my program. > > is there anyeway that i can put this in my perl script in order to run > the program without exporting it from linux Hard to tell without knowing what exactly you're doing. One general solution could be to recompile your program with the option "-rpath /usr/local/lib" added to your ld flags (cf. the ld man page). heiko |
From: Ibrahim S. <sal...@gm...> - 2008-05-13 17:52:30
|
export LD_LIBRARY_PATH=/usr/local/lib i put this command using linux to run my program. is there anyeway that i can put this in my perl script in order to run the program without exporting it from linux thanks in advance |
From: Ibrahim S. <sal...@gm...> - 2008-05-09 20:52:49
|
hello everybody, i have a script that send emails using MIME::LITE, i want that the email i sent it goes to my *sent items.* any idea, it should be easy thank you |
From: Brian H. <bh...@ne...> - 2008-05-07 20:51:57
|
Ibrahim, You might want to try opening up a shell on the channel. See the following code excerpt: my $chan = $ssh->channel(); $chan->blocking(0); $chan->shell(); #send the command to the server through the data channel print $chan "whereis rkhunter\n"; #get the output from the command and push it onto the array while(<$chan>) { push(@output, $_); } Ibrahim Salloum wrote: > Hello everybody, > > i need urgently an net::ssh2 perl small program that connects to a > router and execute one command and display its output in the sceen. i > wrote one but it didn t give me the result i need: > > #!/usr/bin/perl -w > # use warnings and strict to force neat coding, > # and prevent bugs in the future > use strict; > use Net::SSH2; > > my $remotehost="kdca-guard-agm1"; > my $login="reports"; > my $password="wvyonfr5"; > my $chan; > # creating the ssh2 object > my $ssh2 = Net::SSH2->new(); > # connecting and logging in to the machine > die "connect fail" unless ($ssh2->connect($remotehost)); > die "password fail" unless ($ssh2->auth_password($login,$password)); > > $chan=$ssh2->channel(); > $chan->exec("sh ver\n"); > print "EXEC : $_" while <$chan>; > $chan->close; > print "connected\n"; > the favor ll be returned > best regards, > > thank you > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > ------------------------------------------------------------------------ > > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > -- Brian Hill NEXCESS.NET Internet Solutions http://nexcess.net 304 1/2 S. State St. Ann Arbor, MI 48104 1.866.NEXCESS |
From: Ibrahim S. <sal...@gm...> - 2008-05-07 19:52:15
|
Hello everybody, i need urgently an net::ssh2 perl small program that connects to a router and execute one command and display its output in the sceen. i wrote one but it didn t give me the result i need: #!/usr/bin/perl -w # use warnings and strict to force neat coding, # and prevent bugs in the future use strict; use Net::SSH2; my $remotehost="kdca-guard-agm1"; my $login="reports"; my $password="wvyonfr5"; my $chan; # creating the ssh2 object my $ssh2 = Net::SSH2->new(); # connecting and logging in to the machine die "connect fail" unless ($ssh2->connect($remotehost)); die "password fail" unless ($ssh2->auth_password($login,$password)); $chan=$ssh2->channel(); $chan->exec("sh ver\n"); print "EXEC : $_" while <$chan>; $chan->close; print "connected\n"; the favor ll be returned best regards, thank you |
From: Ibrahim S. <sal...@gm...> - 2008-05-06 16:50:39
|
#!/usr/bin/perl -w use strict; use Net::SSH::Perl; my $command="sh ver"; my $router= 'routername'; my(@sshout, $stderr, $exit); my $ssh = Net::SSH::Perl->new($router,debug => 1, protocol => '2,1',use_pty => 1 ); $ssh->login('username','password'); (@sshout, $stderr, $exit) = $ssh->cmd("$command"); print @sshout; this small program allows you to connect to a router via ssh. it look fine except that the result of the command is not shown. any help |
From: Ibrahim S. <sal...@gm...> - 2008-05-06 15:13:31
|
hello, #!/usr/bin/perl -w use strict; use Net::SSH::Perl; my $command="sh ver"; my $prompt='/.*[>#]$/'; my $router= 'name'; my($stdout, $stderr, $exit); my $ssh = Net::SSH::Perl->new($router,debug => 1, protocol => '2,1',use_pty => 1 ); $ssh->login('username','pass'); eval{ ($stdout, $stderr, $exit) = $ssh->cmd($command)}; print $stdout; my aim is to display and pass the output of a command to a variable i want to know where s my mistake , thanks |
From: Ibrahim S. <sal...@gm...> - 2008-05-06 15:07:11
|
From: Brian H. <bh...@ne...> - 2008-04-30 02:22:12
|
Mike, The files being referred to are the ones on the machine you're running the script on. Mike Bates wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I have read the documentation and trying to use auth_publickey on a > Windows box with working keys for PuTTY and SSH Tectia. In this method > what public and private key files are being referred to, the ones on the > Windows system or those on the remote system? Or will the dsa keys I am > using not work with auth_publickey? > > $ssh2->auth_publickey($user, $pubkey, $privkey, $pass ) > ~ or die 'Cannot connect \n'; > > Thanks > Mike > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFIF8tkca0M4pEEYjwRAsXNAKDz8ROel8V8H04iwx1vaeIg+OcnTgCeJLX7 > TRrifUlMtcu4pHwXYXXiboU= > =wtt4 > -----END PGP SIGNATURE----- > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > -- Brian Hill NEXCESS.NET Internet Solutions http://nexcess.net 304 1/2 S. State St. Ann Arbor, MI 48104 1.866.NEXCESS |
From: Mike B. <sx...@co...> - 2008-04-30 01:29:40
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have read the documentation and trying to use auth_publickey on a Windows box with working keys for PuTTY and SSH Tectia. In this method what public and private key files are being referred to, the ones on the Windows system or those on the remote system? Or will the dsa keys I am using not work with auth_publickey? $ssh2->auth_publickey($user, $pubkey, $privkey, $pass ) ~ or die 'Cannot connect \n'; Thanks Mike -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIF8tkca0M4pEEYjwRAsXNAKDz8ROel8V8H04iwx1vaeIg+OcnTgCeJLX7 TRrifUlMtcu4pHwXYXXiboU= =wtt4 -----END PGP SIGNATURE----- |
From: Neven L. <Nev...@pa...> - 2008-04-24 14:09:40
|
Hello, hope this is not considered off topic, but Net::SSH::Perl does play some part. I have noticed a strange difference when logging in to a remote machine via ssh or Net::SSH::Perl: - logging in via ssh authenticates me using keyboard interactive login - logging in via Net::SSH::Perl only works with public key When looking at sshd_configuration of the target server, it has: PasswordAuthentication No ... UsePAM Yes which is common for SuSE. When I set PasswordAuthentication Yes I get the possibility of authenticating via keyboard interactive with Net::SSH::Perl too. To my understanding UsePAM makes sshd use PAM for authentication purposes and ignore the setting of PasswordAuthentication. As the client cannot change this behavior I am wondering what's going on here? Any clues appreciated. Greetings Neven |
From: Mark P. <m.p...@au...> - 2008-04-18 04:16:27
|
Hi, I am just a newbie in using this PERL Module and after a lot of googling, can't still find the answer, hence my email to you guys. I am writing a perl script that would ssh to our foundry boxes. Here is the my test code below require Exporter; @ISA = qw(Exporter); use strict; use warnings 'all'; use Net::SSH::Perl; login_foundry('192.168.11.250', '', 'enable'); sub login_foundry { my ($host,$extra,$rad_com) = @_; return '' if !defined $host; my $user = 'mark'; my $pass = 'password'; my %param; $param{debug}='true'; $param{protocol}=2; my $ssh = Net::SSH::Perl->new($host, %param); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd($rad_com); } 1; But when I execute this script, Here is the result: stibbons: Reading configuration data /home/mark/.ssh/config stibbons: Reading configuration data /etc/ssh_config stibbons: Connecting to 192.168.11.250, port 22. stibbons: Remote version string: SSH-2.0-RomSShell_4.31 stibbons: Remote protocol version 2.0, remote software version RomSShell_4.31 stibbons: Net::SSH::Perl Version 1.30, protocol version 2.0. stibbons: No compat match: RomSShell_4.31 stibbons: Connection established. stibbons: output stibbons: Sent key-exchange init (KEXINIT), wait response. stibbons: Algorithms, c->s: 3des-cbc hmac-sha1 none stibbons: Algorithms, s->c: 3des-cbc hmac-sha1 none stibbons: Entering Diffie-Hellman Group 1 key exchange. stibbons: Sent DH public key, waiting for reply. stibbons: Received host key, type 'ssh-dss'. stibbons: Host '192.168.11.250' is known and matches the host key. stibbons: Computing shared secret key. stibbons: Verifying server signature. stibbons: Waiting for NEWKEYS message. Connection closed by remote host. at /usr/lib/perl5/site_perl/5.8.5/Net/SSH/Perl/Kex.pm line 103 Do you have any idea why is this happening? Your help is mostly appreciated. Cheers, Mark |
From: Amit J. <ami...@ya...> - 2008-03-14 01:30:01
|
I am having problems executing CLI cmds once I login to a device because the PATHS are not set properly in the opened session. When I use the login() & cmd() functions the PATH is very different than when I use the shell() fuction (or use another SSH client to login). Code: #!/usr/bin/perl use warnings; use strict; use Net::SSH::Perl; use Math::BigInt::GMP; my $ssh = Net::SSH::Perl->new($ip,(protocol=>'2,1',port=>'22',debug=>'true')); my $ssh = login("a.b.c.d","username","password"); my ($out, $err, $exit) = $ssh->cmd("echo \$PATH"); print $out; $ssh->shell(); Here's the relevant output: Got channel open confirmation, requesting shell. Requesting service shell on channel 0. channel 1: new [client-session] Requesting channel_open for channel 1. Entering interactive session. Sending command: echo $PATH Requesting service exec on channel 1. channel 1: open confirm rwindow 0 rmax 32768 input_channel_request: rtype exit-status reply 0 channel 1: rcvd eof channel 1: output open -> drain channel 1: rcvd close channel 1: input open -> closed channel 1: close_read channel 1: obuf empty channel 1: output drain -> closed channel 1: close_write channel 1: send close channel 1: full closed /usr/bin:/bin:/usr/sbin:/sbin -------> $PATH when using login & cmd functions channel 3: new [client-session] Requesting channel_open for channel 3. Entering interactive session. Requesting service pty-req on channel 3. Requesting shell. Requesting service shell on channel 3. channel 3: open confirm rwindow 0 rmax 32768 LFab142_5000:admin> echo $PATH echo $PATH /fabos/link_abin:/fabos/link_sbin:/fabos/link_bin -------->> $PATH is different when using $ssh->shell() method The CLI cmds are located under /fabos/link_abin which translates to /fabos/bin. How to setup the defualt paths ? |
From: Sean S. <sst...@ya...> - 2008-03-13 21:50:46
|
Hello, I have a Perl script that opens a connection to numerous remote servers and runs several commands on each. In many cases, a server which has been connected to earlier during the script run will need to have more commands run on it. Therefore to make it more efficient, I keep a list of the open SSH connections and simply reuse those connections to run commands later when necessary. I noticed, though, that I sometimes run out of file descriptors. I did a truss and found that the problem is some "dup"s being done for the STDIN, STDOUT and STDERR every time the Net::SSH::Perl cmd() method is called. Digging into the Net::SSH::Perl code, I discovered that the cmd() method inside SSH2.pm in turn calls "$ssh->_session_channel". The method "_session_channel" contains the following code: my $channel = $cmgr->new_channel( ctype => 'session', local_window => 32*1024, local_maxpacket => 16*1024, remote_name => 'client-session', rfd => _dup('STDIN', '<'), wfd => _dup('STDOUT', '>'), efd => _dup('STDERR', '>')); I don't know much about SSH but I am surprised that a new channel is created every time a cmd is run. I would have thought you could reuse an open channel. But anyway, it's clear that 3 file descriptors are created every time cmd() is called, but I don't see any place where those file descriptors are being released. In the Channel.pm code, I see some comments suggesting that the author needs to go back and close file descriptors at various points (search for "XXX" in the Channel.pm code). It seems odd to me that a new channel is created every time cmd is run suggesting that open channels cannot be reused for some reason, yet there is no attempt to close those unusable open channels. I'm perfectly willing to do some kind of work around, like manually closing the open channels or disconnecting from the remote SSH server and then reconnecting (which hopefully closes the channels and releases all file descriptors associated with that connection), but I see no way to do that. There is a "login()" method for this module, but there is no "logout()" that I know of. Any advice on how to get around this problem would be sincerely appreciated. Thank you, Sean |
From: Isma <ism...@fr...> - 2008-03-12 14:30:57
|
Hi, I try to use this module to scp w/o passwd. Public/private keys are well installed. I am interestd in it because it got a auto_yes feature( to bypass "Are you sure ... connecting(yes/no) ?") But when using : my $scpa = Net::SCP::Expect->new(user=>'root',identity_file=>'/root/.ssh/id_dsa',host=>$host); It asks me for a passwd . Why ? Am i wrong ? Others things to use ? Note : I can ssh without passwd between hosts. Thanks in advance |
From: Isma <ism...@gm...> - 2008-03-12 09:47:12
|
Hi, I try to use this module to scp w/o passwd. Public/private keys are well installed. I am interestd in it because it got a auto_yes feature( to bypass "Are you sure ... connecting(yes/no) ?") But when using : my $scpa = Net::SCP::Expect->new(user=>'root',identity_file=>'/root/.ssh/id_dsa',host=>$host); It asks me for a passwd . Why ? Am i wrong ? Others things to use ? Note : I can ssh without passwd between hosts. Thanks in advance |
From: Bruner, T. <tb...@sa...> - 2008-03-11 23:17:16
|
Documentation seems to suggest that $ssh->login($user, $pass) will work for password authentication. That doesn't appear to be the case. Why is that? I'm not asking for a dissertation on why it's bad to store passwords in a program, but why the docs say you can do it but it doesn't work. It used to work in an older version, why not now? todd |
From: Bruner, T. <tb...@sa...> - 2008-03-11 21:39:41
|
Turns out that Net::SSH::Perl was looking for my .ssh directory in /. Couldn’t figure out how to change that expectation. So after looking at Perl/Util/Hosts.pm, I guessed that it was not getting the correct home directory. Setting $ENV{HOME} right before creation of the Net::SSH::Perl object fixed that. I’d still like to disable the “data is” junk from my logs though, any clues? On 3/6/08 6:08 PM, "tbruner" <tb...@sa...> wrote: Hello: I have written a perl program that ssh’s to another system, executes a command and uses the output that is returned. It is failing in my Apache mod_perl environment. (See log below) (Net-SSH-Perl 1.30, Perl 5.8.5, talking to a F-Secure SSH 3.2.3 (build 14) on sparc-sun-solaris2.9) On STDERR, I’m getting hundreds of “data is ‘??w?f0Z'” type messages. When run from the command line, $stdout will contain the expected output, however, I need to run this in a mod_perl apache environment. My module that contains this snippet fails, possibly due to these “data is” messages. Here’s the apache error log: [Thu Mar 6 16:48:26 2008] [debug] ssh before eval data is 's?7?j?' data is '?[#?S"g8' data is '???v??|' data is '"?b???' data is 'mV? ?e?' data is 'xH?Jk' data is '?????' data is '&?Aki?\' data is '??(????' data is '??A??' data is ',?MI\ ata is '?z???N`S' data is 'E?>䎳??' data is '???N???' data is 'r²v;FÌ[þ' [Thu Mar 6 16:49:04 2008] [debug] Login failed: switchwi @ host123 Here’s the program snippet: my $ssh = Net::SSH::Perl->new( $host, protocol => 2, cipher => "3des-cbc", debug => 1, options => [ "PasswordAuthentication yes", "IdentityFile /opt/httpd/.ssh2/id_dsa", "UserKnownHostsFile /opt/httpd/.ssh2/knownhosts2", ]); $self->print(“ssh before eval”); eval { $ssh->login($user, $pass) or die "Could not login to $host !"; $self->log(“Login Failed: $user @ $host”); }; if ($@) { print "Could not login to $host!!\n"; } my ($stdout,$stderr,$exit) = $ssh->cmd($cmd); print "stdout = $stdout\n"; if ($exit ne 0) { print "CMD failed. $user @ $host : $stderr ; $stdout\n"; } Here’s the Command Line debug ouput: webhost: Reading configuration data /home/tbruner/.ssh/config webhost: Reading configuration data /etc/ssh_config webhost: Connecting to host123, port 22. webhost: Remote version string: SSH-2.0-3.2.9 F-SECURE SSH 3.2.3 SNL2-1^M webhost: Remote protocol version 2.0, remote software version 3.2.9 F-SECURE SSH 3.2.3 SNL2-1^M webhost: Net::SSH::Perl Version 1.30, protocol version 2.0. webhost: No compat match: 3.2.9 F-SECURE SSH 3.2.3 SNL2-1^M. webhost: Connection established. webhost: Sent key-exchange init (KEXINIT), wait response. webhost: Algorithms, c->s: 3des-cbc hmac-sha1 none webhost: Algorithms, s->c: 3des-cbc hmac-sha1 none webhost: Entering Diffie-Hellman Group 1 key exchange. webhost: Sent DH public key, waiting for reply. webhost: Received host key, type 'ssh-dss'. webhost: Host 'host123' is known and matches the host key. webhost: Computing shared secret key. webhost: Verifying server signature. webhost: Waiting for NEWKEYS message. webhost: Enabling incoming encryption/MAC/compression. webhost: Send NEWKEYS, enable outgoing encryption/MAC/compression. webhost: Sending request for user-authentication service. data is 'I^îòÏ'(s' ... this repeats a lot... webhost: Service accepted: ssh-userauth. webhost: Trying empty user-authentication request. data is '^[^NÖ À}Oã' ... more data is lines .... webhost: Authentication methods that can continue: gssapi,gssapi-with-mic,ker...@ss...,ker...@ss...,password. webhost: Next method to try is password. webhost: Trying password authentication. data is '®bx"^P^V*~' ... more data is lines ... webhost: Login completed, opening dummy shell channel. webhost: channel 0: new [client-session] webhost: Requesting channel_open for channel 0. data is '^?Í^BT$0z' ... more ... webhost: channel 0: open confirm rwindow 100000 rmax 16384 webhost: Got channel open confirmation, requesting shell. webhost: Requesting service shell on channel 0. data is '©ß¼ú<82>ÿ²<93>' ... webhost: channel 1: new [client-session] webhost: Requesting channel_open for channel 1. ... webhost: Sending command: /opt/foo/bar/bin/giit.pl -n zzz123 -x webhost: Requesting service exec on channel 1. ... even more data lines ... webhost: input_channel_request: rtype exit-status reply 0 data is 's~ ^,Õ<93>{' data is '^C¹%Øô%÷<95>' data is 'L^T<8e>£BløS' data is '<9f>^XÓ^P<9c>^H<9e><9b>' webhost: channel 1: rcvd close webhost: channel 1: output open -> drain webhost: channel 1: input open -> closed webhost: channel 1: close_read webhost: channel 1: obuf empty webhost: channel 1: output drain -> closed webhost: channel 1: close_write webhost: channel 1: send close data is 'Úp^Ed-+Â ' data is 'Y$n^DpMô^]' data is '<81>^R@Ë^]ç)é' data is '^Y_ý&brkbar;ß<8c><8f>®' webhost: channel 1: full closed stdout = CPP,203938,Unmanaged Gi3/1,171572,Disabled ... I have verified that I can ssh from the command line of the webserver to the destination host with the username and password in question. Any help will be greatly appreciated. Todd |
From: Bruner, T. <tb...@sa...> - 2008-03-07 01:08:31
|
Hello: I have written a perl program that ssh’s to another system, executes a command and uses the output that is returned. It is failing in my Apache mod_perl environment. (See log below) (Net-SSH-Perl 1.30, Perl 5.8.5, talking to a F-Secure SSH 3.2.3 (build 14) on sparc-sun-solaris2.9) On STDERR, I’m getting hundreds of “data is ‘??w?f0Z'” type messages. When run from the command line, $stdout will contain the expected output, however, I need to run this in a mod_perl apache environment. My module that contains this snippet fails, possibly due to these “data is” messages. Here’s the apache error log: [Thu Mar 6 16:48:26 2008] [debug] ssh before eval data is 's?7?j?' data is '?[#?S"g8' data is '???v??|' data is '"?b???' data is 'mV? ?e?' data is 'xH?Jk' data is '?????' data is '&?Aki?\' data is '??(????' data is '??A??' data is ',?MI\ ata is '?z???N`S' data is 'E?>䎳??' data is '???N???' data is 'r²v;FÌ[þ' [Thu Mar 6 16:49:04 2008] [debug] Login failed: switchwi @ host123 Here’s the program snippet: my $ssh = Net::SSH::Perl->new( $host, protocol => 2, cipher => "3des-cbc", debug => 1, options => [ "PasswordAuthentication yes", "IdentityFile /opt/httpd/.ssh2/id_dsa", "UserKnownHostsFile /opt/httpd/.ssh2/knownhosts2", ]); $self->print(“ssh before eval”); eval { $ssh->login($user, $pass) or die "Could not login to $host !"; $self->log(“Login Failed: $user @ $host”); }; if ($@) { print "Could not login to $host!!\n"; } my ($stdout,$stderr,$exit) = $ssh->cmd($cmd); print "stdout = $stdout\n"; if ($exit ne 0) { print "CMD failed. $user @ $host : $stderr ; $stdout\n"; } Here’s the Command Line debug ouput: webhost: Reading configuration data /home/tbruner/.ssh/config webhost: Reading configuration data /etc/ssh_config webhost: Connecting to host123, port 22. webhost: Remote version string: SSH-2.0-3.2.9 F-SECURE SSH 3.2.3 SNL2-1^M webhost: Remote protocol version 2.0, remote software version 3.2.9 F-SECURE SSH 3.2.3 SNL2-1^M webhost: Net::SSH::Perl Version 1.30, protocol version 2.0. webhost: No compat match: 3.2.9 F-SECURE SSH 3.2.3 SNL2-1^M. webhost: Connection established. webhost: Sent key-exchange init (KEXINIT), wait response. webhost: Algorithms, c->s: 3des-cbc hmac-sha1 none webhost: Algorithms, s->c: 3des-cbc hmac-sha1 none webhost: Entering Diffie-Hellman Group 1 key exchange. webhost: Sent DH public key, waiting for reply. webhost: Received host key, type 'ssh-dss'. webhost: Host 'host123' is known and matches the host key. webhost: Computing shared secret key. webhost: Verifying server signature. webhost: Waiting for NEWKEYS message. webhost: Enabling incoming encryption/MAC/compression. webhost: Send NEWKEYS, enable outgoing encryption/MAC/compression. webhost: Sending request for user-authentication service. data is 'I^îòÏ'(s' ... this repeats a lot... webhost: Service accepted: ssh-userauth. webhost: Trying empty user-authentication request. data is '^[^NÖ À}Oã' ... more data is lines .... webhost: Authentication methods that can continue: gssapi,gssapi-with-mic,ker...@ss...,ker...@ss...,password. webhost: Next method to try is password. webhost: Trying password authentication. data is '®bx"^P^V*~' ... more data is lines ... webhost: Login completed, opening dummy shell channel. webhost: channel 0: new [client-session] webhost: Requesting channel_open for channel 0. data is '^?Í^BT$0z' ... more ... webhost: channel 0: open confirm rwindow 100000 rmax 16384 webhost: Got channel open confirmation, requesting shell. webhost: Requesting service shell on channel 0. data is '©ß¼ú<82>ÿ²<93>' ... webhost: channel 1: new [client-session] webhost: Requesting channel_open for channel 1. ... webhost: Sending command: /opt/foo/bar/bin/giit.pl -n zzz123 -x webhost: Requesting service exec on channel 1. ... even more data lines ... webhost: input_channel_request: rtype exit-status reply 0 data is 's~ ^,Õ<93>{' data is '^C¹%Øô%÷<95>' data is 'L^T<8e>£BløS' data is '<9f>^XÓ^P<9c>^H<9e><9b>' webhost: channel 1: rcvd close webhost: channel 1: output open -> drain webhost: channel 1: input open -> closed webhost: channel 1: close_read webhost: channel 1: obuf empty webhost: channel 1: output drain -> closed webhost: channel 1: close_write webhost: channel 1: send close data is 'Úp^Ed-+Â ' data is 'Y$n^DpMô^]' data is '<81>^R@Ë^]ç)é' data is '^Y_ý&brkbar;ß<8c><8f>®' webhost: channel 1: full closed stdout = CPP,203938,Unmanaged Gi3/1,171572,Disabled ... I have verified that I can ssh from the command line of the webserver to the destination host with the username and password in question. Any help will be greatly appreciated. Todd |
From: Isma <ism...@gm...> - 2008-02-19 16:04:00
|
Hi, You're lucky (I believe) I work too on Enterasys switches. Use rather Net::Telnet::Cisco : method $session->cmd() , it works for me ! I want to change passwords on my switches (A2/B2/V2) :commands are differents for : -A2/B2 -V2 Here's a code snippet exple : foreach(@hostname) { $session = Net::Telnet::Cisco->new ( Host => $adresse{$_}, Prompt => '/.*[\$>#]/', Input_log => "$adresse{$_}".'_switch.log', Errmode =>"return" ); $i++; print "$_ | $adresse{$_} | $type{$_} "; if (ref $session ne "Net::Telnet::Cisco") { print "$adresse{$_} not reachable\n"; } else { $session->login('admin',$connect); $erreur=$session->errmsg(); if (!$erreur) { if ($type{$_} eq 'SW_V2') { $session->cmd('configure'); $session->cmd("username admin password 0 $pwd"); $session->cmd('exit'); $session->cmd('copy running-config startup-config'); $session->cmd(''); $session->cmd('exit'); } else { $session->cmd('set password admin'); $session->cmd("$pwd"); $session->cmd("$pwd"); $session->cmd('save config'); $session->cmd('exit'); } $session->close; } else { if ($erreur =~ /[Aa]uthentication/) { print "$adresse{$_} => authentication failed\n"; } else { print "$adresse{$_} : could not log in: $erreur\n"; } } } } 2008/2/19, Nicholas Scholl <pro...@ya...>: > Hey everyone, > > I am a Network Technician for Morrisville State College and Im attempting to use Net::SSH::Perl to SSH into all the switches we have on campus and retrieve some data from them. Unfortunately this isn't going my way. I have below my code and debug output. > > > Help with this would make my day, > > Thanks, > > Nicholas > > > Code: > > #!/usr/bin/perl > > use Net::SSH::Perl; > > # get the addresses from the a file the user inputs > > #ask the user where the file is > print "Please enter the path to the list of devices: "; > $filepath = <STDIN> ; > open(IPS, $filepath); > @addyarray = <IPS>; > close(IPS); > > #ask the user what the username and password are > print "Please enter the username to login as: "; > $user = <STDIN> ; > chomp($user); > > #ask the user what the password is > print "Please enter the password for " . $user . ":"; > $pass = <STDIN> ; > chomp($pass); > > #ask the user where the out file is > print "Please enter the filename you want the data to be placed in: "; > $outfile = <STDIN> ; > chomp($outfile); > > #open the file to append data > open(OUT, ">>$outfile"); > > #below is a loop that gets the IP and connects to the device via SSH > foreach $address (@addyarray) # Visit each address in turn > # and call it address > { > print "currently working on device " . $address; > my $ssh = Net::SSH::Perl->new($address, debug => true); > $ssh->login($user, $pass); > my $cmd="show system"; > my ($stdout, $stderr, $exit) = $ssh->cmd($cmd); > print OUT "-----------------------------------------------\n"; > print OUT "Information for " . $address; > print OUT "-----------------------------------------------\n"; > print OUT "output for command" . $cmd; > print OUT $stdout . "\n"; > print OUT "errors for command" . $cmd; > print OUT $stderr . "\n"; > print OUT "\n\n"; > > my $cmd="show ver"; > my ($stdout, $stderr, $exit) = $ssh->cmd($cmd); > print OUT "---------------------\n"; > print OUT "output for command" . $cmd; > print OUT $stdout . "\n"; > print OUT "errors for command" . $cmd; > print OUT $stderr . "\n"; > print OUT "\n\n\n"; > } > > #close the output file and save changes > close(OUT); > > #tell the user when we are done > print "Information retrieval complete \n"; > > > Debug info: > > currently working on device 10.255.101.198 > riley: Reading configuration data /home/nicholas/.ssh/config > riley: Reading configuration data /etc/ssh_config > riley: Connecting to 10.255.101.198 > , port 22. > riley: Remote version string: SSH-2.0-FreSSH.0.8 > > riley: Remote protocol version 2.0, remote software version FreSSH.0.8 > riley: Net::SSH::Perl Version 1.30, protocol version 2.0. > riley: No compat match: FreSSH.0.8. > riley: Connection established. > riley: Sent key-exchange init (KEXINIT), wait response. > riley: Algorithms, c->s: 3des-cbc hmac-sha1 none > riley: Algorithms, s->c: 3des-cbc hmac-sha1 none > riley: Entering Diffie-Hellman Group 1 key exchange. > riley: Sent DH public key, waiting for reply. > riley: Received host key, type 'ssh-dss'. > riley: Permanently added '10.255.101.198 > ' to the list of known hosts. > riley: Computing shared secret key. > riley: Verifying server signature. > riley: Waiting for NEWKEYS message. > riley: Enabling incoming encryption/MAC/compression. > riley: Send NEWKEYS, enable outgoing encryption/MAC/compression. > riley: Sending request for user-authentication service. > riley: Service accepted: ssh-userauth. > riley: Trying empty user-authentication request. > riley: Authentication methods that can continue: password. > riley: Next method to try is password. > riley: Trying password authentication. > riley: Login completed, opening dummy shell channel. > riley: channel 0: new [client-session] > riley: Requesting channel_open for channel 0. > riley: channel 0: open confirm rwindow 0 rmax 16384 > riley: Got channel open confirmation, requesting shell. > riley: Requesting service shell on channel 0. > riley: channel 1: new [client-session] > riley: Requesting channel_open for channel 1. > riley: Entering interactive session. > riley: Channel open failure: 1: reason 1: unable to create channel > riley: channel 2: new [client-session] > riley: Requesting channel_open for channel 2. > riley: Entering interactive session. > riley: channel 0: rcvd close > riley: channel 0: output open -> drain > riley: channel 0: input open -> closed > riley: channel 0: close_read > Information retrieval complete > > output to file: > > ----------------------------------------------- > Information for 10.255.101.198 > ----------------------------------------------- > output for commandshow system > errors for commandshow system > > > --------------------- > output for commandshow ver > errors for commandshow ver > > > > > ____________________________________________________________________________________ > Never miss a thing. Make Yahoo your home page. > http://www.yahoo.com/r/hs > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > |
From: Nicholas S. <pro...@ya...> - 2008-02-19 15:46:02
|
Hey everyone, I am a Network Technician for Morrisville State College and Im attempting to use Net::SSH::Perl to SSH into all the switches we have on campus and retrieve some data from them. Unfortunately this isn't going my way. I have below my code and debug output. Help with this would make my day, Thanks, Nicholas Code: #!/usr/bin/perl use Net::SSH::Perl; # get the addresses from the a file the user inputs #ask the user where the file is print "Please enter the path to the list of devices: "; $filepath = <STDIN> ; open(IPS, $filepath); @addyarray = <IPS>; close(IPS); #ask the user what the username and password are print "Please enter the username to login as: "; $user = <STDIN> ; chomp($user); #ask the user what the password is print "Please enter the password for " . $user . ":"; $pass = <STDIN> ; chomp($pass); #ask the user where the out file is print "Please enter the filename you want the data to be placed in: "; $outfile = <STDIN> ; chomp($outfile); #open the file to append data open(OUT, ">>$outfile"); #below is a loop that gets the IP and connects to the device via SSH foreach $address (@addyarray) # Visit each address in turn # and call it address { print "currently working on device " . $address; my $ssh = Net::SSH::Perl->new($address, debug => true); $ssh->login($user, $pass); my $cmd="show system"; my ($stdout, $stderr, $exit) = $ssh->cmd($cmd); print OUT "-----------------------------------------------\n"; print OUT "Information for " . $address; print OUT "-----------------------------------------------\n"; print OUT "output for command" . $cmd; print OUT $stdout . "\n"; print OUT "errors for command" . $cmd; print OUT $stderr . "\n"; print OUT "\n\n"; my $cmd="show ver"; my ($stdout, $stderr, $exit) = $ssh->cmd($cmd); print OUT "---------------------\n"; print OUT "output for command" . $cmd; print OUT $stdout . "\n"; print OUT "errors for command" . $cmd; print OUT $stderr . "\n"; print OUT "\n\n\n"; } #close the output file and save changes close(OUT); #tell the user when we are done print "Information retrieval complete \n"; Debug info: currently working on device 10.255.101.198 riley: Reading configuration data /home/nicholas/.ssh/config riley: Reading configuration data /etc/ssh_config riley: Connecting to 10.255.101.198 , port 22. riley: Remote version string: SSH-2.0-FreSSH.0.8 riley: Remote protocol version 2.0, remote software version FreSSH.0.8 riley: Net::SSH::Perl Version 1.30, protocol version 2.0. riley: No compat match: FreSSH.0.8. riley: Connection established. riley: Sent key-exchange init (KEXINIT), wait response. riley: Algorithms, c->s: 3des-cbc hmac-sha1 none riley: Algorithms, s->c: 3des-cbc hmac-sha1 none riley: Entering Diffie-Hellman Group 1 key exchange. riley: Sent DH public key, waiting for reply. riley: Received host key, type 'ssh-dss'. riley: Permanently added '10.255.101.198 ' to the list of known hosts. riley: Computing shared secret key. riley: Verifying server signature. riley: Waiting for NEWKEYS message. riley: Enabling incoming encryption/MAC/compression. riley: Send NEWKEYS, enable outgoing encryption/MAC/compression. riley: Sending request for user-authentication service. riley: Service accepted: ssh-userauth. riley: Trying empty user-authentication request. riley: Authentication methods that can continue: password. riley: Next method to try is password. riley: Trying password authentication. riley: Login completed, opening dummy shell channel. riley: channel 0: new [client-session] riley: Requesting channel_open for channel 0. riley: channel 0: open confirm rwindow 0 rmax 16384 riley: Got channel open confirmation, requesting shell. riley: Requesting service shell on channel 0. riley: channel 1: new [client-session] riley: Requesting channel_open for channel 1. riley: Entering interactive session. riley: Channel open failure: 1: reason 1: unable to create channel riley: channel 2: new [client-session] riley: Requesting channel_open for channel 2. riley: Entering interactive session. riley: channel 0: rcvd close riley: channel 0: output open -> drain riley: channel 0: input open -> closed riley: channel 0: close_read Information retrieval complete output to file: ----------------------------------------------- Information for 10.255.101.198 ----------------------------------------------- output for commandshow system errors for commandshow system --------------------- output for commandshow ver errors for commandshow ver ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |