-
-
Save mlafeldt/841944 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python | |
import sys, paramiko | |
if len(sys.argv) < 5: | |
print "args missing" | |
sys.exit(1) | |
hostname = sys.argv[1] | |
password = sys.argv[2] | |
source = sys.argv[3] | |
dest = sys.argv[4] | |
username = "root" | |
port = 22 | |
try: | |
t = paramiko.Transport((hostname, port)) | |
t.connect(username=username, password=password) | |
sftp = paramiko.SFTPClient.from_transport(t) | |
sftp.get(source, dest) | |
finally: | |
t.close() |
#!/usr/bin/env python | |
import sys, paramiko | |
if len(sys.argv) < 4: | |
print "args missing" | |
sys.exit(1) | |
hostname = sys.argv[1] | |
password = sys.argv[2] | |
command = sys.argv[3] | |
username = "admin" | |
port = 22 | |
try: | |
client = paramiko.SSHClient() | |
client.load_system_host_keys() | |
client.set_missing_host_key_policy(paramiko.WarningPolicy) | |
client.connect(hostname, port=port, username=username, password=password) | |
stdin, stdout, stderr = client.exec_command(command) | |
print stdout.read(), | |
finally: | |
client.close() |
How can I connect to a host file using a pem key file like
ssh -i ~/.ssh/mykey.pem [email protected]
Hi Ricardo,
You need to include 'ssh.connect(host, username="", password="", pkey=None, key_filename="")' option providing pem file.
Hi Ricardo,
I want to pass encrypted password to connect method. How can I do that. I could not find the documentation on paramiko site.
Hi kritisingh,
You could use getpass for that: https://pymotw.com/2/getpass/
That is fine with ssh ... but in "pure paramiko" how would you formulate http://docs.paramiko.org/en/2.4/api/sftp.html#paramiko.sftp_client.SFTPClient.listdir ?
How can I ssh to multiple devices
Hey can anyone tell me that, is SSH exploit public key script is available or not,
how to write command for windows remote server path.
Hey,
how can I use these openssh options on paramiko?
ssh -oHostKeyAlgorithms=+ssh-dss -oKexAlgorithms=+diffie-hellman-group1-sha1 -c aes256-cbc user@host
line 19 in ssh_demo.py should be
client.set_missing_host_key_policy(paramiko.WarningPolicy())