Add exercise 9 by script-hacking course
Signed-off-by: Manuel Vergara <manuel@vergaracarmona.es>
This commit is contained in:
parent
e4ac2ba3b4
commit
a9d3a139be
23
scripts-hacking-etico/src/09-paramiko.py
Normal file
23
scripts-hacking-etico/src/09-paramiko.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user