• Publicidad

Net::SSH::Perl

Aquí encontrarás todo lo que sea específicamente acerca de módulos de Perl. Ya sea que estás compartiendo tu módulo, un manual o simplemente tienes una duda acerca de alguno.

Net::SSH::Perl

Notapor rockhoward » 2010-04-19 09:30 @437

Hola, mi nombre es Leandro y soy nuevo en el foro, acudo a éste a ver si alguien puede ayudarme :P.

Estoy tratando de conectar con un servidor SSH desde código Perl. Estoy probando con la librería ésta, pero no me toma el password. Necesito que conecte sin tener que poner el password.

También probé el Net::SSH2 pero me tira o illegal o un error de segmentation.

Les dejo el código que tengo hecho pera la conexión.

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use Net::SSH::Perl;
  6.  
  7. my $host = '10.15.19.64';
  8. my $pass = 'usuario';
  9. my $user = 'password';
  10. my $cmd  = 'pwd';
  11.  
  12.  
  13. #my $host = '10.225.173.148';
  14. #my $pass = 'argentina';
  15. #my $user = 'arg09';
  16. #my $cmd  = 'pwd';
  17.  
  18. my $ssh = Net::SSH::Perl->new($host, protocol => '2,1', debug => 1,interactive=>0);
  19.  
  20. $ssh->login($user,$pass);
  21.  
  22.  
  23. my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
  24. print $stdout, "\n";
  25.  
  26.  
  27.  
  28. exit;
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4


Este código me tira esto:


Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
./test_lna.pl
gentoo: Reading configuration data /root/.ssh/config
gentoo: Reading configuration data /etc/ssh_config
gentoo: Allocated local port 1023.
gentoo: Connecting to 10.15.19.64, port 22.
gentoo: Remote version string: SSH-2.0-4.4.2.3 SSH Secure Shell

gentoo: Remote protocol version 2.0, remote software version 4.4.2.3 SSH Secure Shell
gentoo: Net::SSH::Perl Version 1.30, protocol version 2.0.
.entoo: No compat match: 4.4.2.3 SSH Secure Shell
gentoo: Connection established.
gentoo: Sent key-exchange init (KEXINIT), wait response.
gentoo: Algorithms, c->s: 3des-cbc hmac-sha1 none
gentoo: Algorithms, s->c: 3des-cbc hmac-sha1 none
gentoo: Entering Diffie-Hellman Group 1 key exchange.
gentoo: Sent DH public key, waiting for reply.
gentoo: Received host key, type 'ssh-dss'.
gentoo: Host '10.15.19.64' is known and matches the host key.
gentoo: Computing shared secret key.
gentoo: Verifying server signature.
gentoo: Waiting for NEWKEYS message.
gentoo: Enabling incoming encryption/MAC/compression.
gentoo: Send NEWKEYS, enable outgoing encryption/MAC/compression.
gentoo: Sending request for user-authentication service.
gentoo: Service accepted: ssh-userauth.
gentoo: Trying empty user-authentication request.
gentoo: Authentication methods that can continue: hostbased,publickey,keyboard-interactive,password.
gentoo: Next method to try is publickey.
gentoo: Next method to try is password.
gentoo: Trying password authentication.
gentoo: Authentication methods that can continue: hostbased,publickey,keyboard-interactive,password.
gentoo: Next method to try is publickey.
gentoo: Next method to try is password.
gentoo: Trying password authentication.
gentoo: Authentication methods that can continue: hostbased,publickey,keyboard-interactive,password.
gentoo: Next method to try is publickey.
gentoo: Next method to try is password.
gentoo: Trying password authentication.
gentoo: Authentication methods that can continue: hostbased,publickey,keyboard-interactive.
gentoo: Next method to try is publickey.
Permission denied at ./test_lna.pl line 20
 
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4



Desde ya, muchas gracias.
rockhoward
Perlero nuevo
Perlero nuevo
 
Mensajes: 4
Registrado: 2010-04-19 09:19 @430

Publicidad

Re: Net::SSH::Perl

Notapor explorer » 2010-04-19 11:14 @510

Bienvenido a los foros de Perl en Español, rockhoward.

He probado tu código, con uno de mis servidores, y sí que me ha funcionado. Bueno, al principio no: había metido mal la contraseña.

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
joaquin: Reading configuration data /home/explorer/.ssh/config
joaquin: Reading configuration data /etc/ssh_config
joaquin: Connecting to aprosi16.aprosi.net, port 22.
joaquin: Remote protocol version 2.0, remote software version OpenSSH_4.0 Debian
joaquin: Net::SSH::Perl Version 1.34, protocol version 2.0.
joaquin: No compat match: OpenSSH_4.0 Debian.
joaquin: Connection established.
joaquin: Sent key-exchange init (KEXINIT), wait response.
joaquin: Algorithms, c->s: 3des-cbc hmac-sha1 none
joaquin: Algorithms, s->c: 3des-cbc hmac-sha1 none
joaquin: Entering Diffie-Hellman Group 1 key exchange.
joaquin: Sent DH public key, waiting for reply.
joaquin: Received host key, type 'ssh-dss'.
joaquin: Host 'aprosi16.aprosi.net' is known and matches the host key.
joaquin: Computing shared secret key.
joaquin: Verifying server signature.
joaquin: Waiting for NEWKEYS message.
joaquin: Send NEWKEYS.
joaquin: Enabling encryption/MAC/compression.
joaquin: Sending request for user-authentication service.
joaquin: Service accepted: ssh-userauth.
joaquin: Trying empty user-authentication request.
joaquin: Authentication methods that can continue: publickey,password.
joaquin: Next method to try is publickey.
joaquin: Next method to try is password.
joaquin: Trying password authentication.
joaquin: Login completed, opening dummy shell channel.
joaquin: channel 0: new [client-session]
joaquin: Requesting channel_open for channel 0.
joaquin: channel 0: open confirm rwindow 0 rmax 32768
joaquin: Got channel open confirmation, requesting shell.
joaquin: Requesting service shell on channel 0.
joaquin: channel 1: new [client-session]
joaquin: Requesting channel_open for channel 1.
joaquin: Entering interactive session.
joaquin: Sending command: pwd
joaquin: Sending command: pwd
joaquin: Requesting service exec on channel 1.
joaquin: channel 1: open confirm rwindow 0 rmax 32768
joaquin: input_channel_request: rtype exit-status reply 0
joaquin: channel 1: rcvd eof
joaquin: channel 1: output open -> drain
joaquin: channel 1: rcvd close
joaquin: channel 1: input open -> closed
joaquin: channel 1: close_read
joaquin: channel 1: obuf empty
joaquin: channel 1: output drain -> closed
joaquin: channel 1: close_write
joaquin: channel 1: send close
joaquin: channel 1: full closed
/home/explorer.joaki.com
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14477
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Net::SSH::Perl

Notapor rockhoward » 2010-04-19 12:19 @555

¿No sabes problema de qué puede ser, entonces? ¿Que no me loguee a mi? ¿Alguna versión vieja de algo?
rockhoward
Perlero nuevo
Perlero nuevo
 
Mensajes: 4
Registrado: 2010-04-19 09:19 @430

Re: Net::SSH::Perl

Notapor explorer » 2010-04-19 12:28 @561

Hummm...

Primero, haría una prueba desde un cliente de SSH, para ver si me deja entrar como un usuario normal.

Luego, quitaría lo del 'protocolo', y probar.

Si no, cambiaría 'interactive' a 1, y probar.

Lo que me dio la pista es en el registro /var/log/syslog, donde me dijo qué es lo que pasaba y por qué no me dejaba entrar.
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14477
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Net::SSH::Perl

Notapor rockhoward » 2010-04-19 14:49 @659

Con el 'interactive' en 1 entra perfecto. Voy a ver los logs a ver si encuentro algo :D.

Gracias, voy a seguir probando.

Estoy buscando el archivo syslog y la verdad, no lo tengo, por lo menos en esa ruta que especificas, ¿no sabes dónde puede estar sino?
rockhoward
Perlero nuevo
Perlero nuevo
 
Mensajes: 4
Registrado: 2010-04-19 09:19 @430

Re: Net::SSH::Perl

Notapor explorer » 2010-04-19 14:56 @664

Depende del sistema operativo que estés usando...
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14477
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Net::SSH::Perl

Notapor rockhoward » 2010-04-19 15:09 @673

Tirando un uname -r me tira:
2.6.12-gentoo-r6

Bueno, ya lo hice andar :D

Pueden cerrar el tema, ¡ gracias por la ayuda !
rockhoward
Perlero nuevo
Perlero nuevo
 
Mensajes: 4
Registrado: 2010-04-19 09:19 @430


Volver a Módulos

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 4 invitados

cron