From a9d3a139beadf6d0e657276ccb785c02ed217f52 Mon Sep 17 00:00:00 2001 From: Manuel Vergara Date: Thu, 8 Jun 2023 20:27:35 +0200 Subject: [PATCH] Add exercise 9 by script-hacking course Signed-off-by: Manuel Vergara --- scripts-hacking-etico/src/09-paramiko.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts-hacking-etico/src/09-paramiko.py diff --git a/scripts-hacking-etico/src/09-paramiko.py b/scripts-hacking-etico/src/09-paramiko.py new file mode 100644 index 0000000..9f0feee --- /dev/null +++ b/scripts-hacking-etico/src/09-paramiko.py @@ -0,0 +1,23 @@ +import paramiko + +# Crear una instancia del cliente SSH +client = paramiko.SSHClient() + +# Configurar el cliente para aceptar automáticamente la clave del servidor +client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + +# Conectar al servidor SSH +client.connect( + '192.168.1.1', + port=666, + username='admin', + password='Passw0rd' +) + +# Ejecutar comandos en el servidor +stdin, stdout, stderr = client.exec_command('ls') +output = stdout.read().decode() +print(output) + +# Cerrar la conexión SSH +client.close()