Commit 724bec4a authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added communication test with ssh keys.

parent 73fdbedb
Loading
Loading
Loading
Loading

tests/ssh_keys_test.py

0 → 100644
+16 −0
Original line number Diff line number Diff line
import paramiko

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ip = "192.168.0.18"
privateKeyFile = "/home/cristiano/.ssh/test_rsa"

privateKey = paramiko.RSAKey.from_private_key_file(privateKeyFile)
client.load_system_host_keys()
client.connect(ip, port = 22, username = 'centos', pkey = privateKey, timeout = 11)

stdin, stdout, stderr = client.exec_command("df -h")
exitCode = stdout.channel.recv_exit_status()
result = stdout.readlines()
print(result)