diff options
| author | jerome <jerome@xlinfo.fr> | 2024-09-17 15:32:53 +0200 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2024-09-17 15:32:53 +0200 |
| commit | 550497e907868ac0249a18eef2a0fb7f5bcd9ed8 (patch) | |
| tree | 5690fce051444c9897a2bcf610d174b20dfe6718 /sshClient.py | |
| parent | cdb4e2f17863038e28ab063415f59cc4d94491d6 (diff) | |
| download | python-550497e907868ac0249a18eef2a0fb7f5bcd9ed8.tar.gz python-550497e907868ac0249a18eef2a0fb7f5bcd9ed8.zip | |
scapy
Diffstat (limited to 'sshClient.py')
| -rw-r--r-- | sshClient.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sshClient.py b/sshClient.py new file mode 100644 index 0000000..62231a4 --- /dev/null +++ b/sshClient.py @@ -0,0 +1,19 @@ +import sys, paramiko + +def sshClient(hostname, username, password,cmd): + client = paramiko.SSHClient() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + client.connect(hostname, username=username, password=password) + _stdin, _stdout,_stderr = client.exec_command(cmd) + print(_stdout.read().decode()) + client.close() + +if __name__ == "__main__": + try: + hostname = sys.argv[1] + username = sys.argv[2] + password = input("Mot de passe : ") + cmd = sys.argv[3] + sshClient(hostname, username, password, cmd) + except IndexError: + print(f"{sys.argv[0]} demande des arguments") |
