Created
September 19, 2013 21:28
-
-
Save eliezerfot123/6630102 to your computer and use it in GitHub Desktop.
Revisions
-
eliezerfot123 created this gist
Sep 19, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ #!/usr/bin/env python # Librerias necesarias import paramiko import os # Datos para la conexion SSH ssh_servidor = '10.0.70.44' ssh_usuario = 'tuusuario' ssh_clave = 'tucontraseña' ssh_puerto = 22 comando = 'ls' # Conectamos al servidor conexion = paramiko.Transport((ssh_servidor, ssh_puerto)) conexion.connect(username = ssh_usuario, password = ssh_clave) # Abrimos una sesion en el servidor canal = conexion.open_session() canal.exec_command(comando) # Y vamos a ver la salida salida = canal.makefile('rb', -1).readlines() if salida: for i in salida: # Si ha ido todo bien mostramos el listado de directorios print i else: # Si se ha producido algun error lo mostramos print canal.makefile_stderr('rb', -1).readlines() conexion.close()