Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko
- ips = [host1, host2]
- logins = {host1: username1, host2: username2}
- passwords = {host1: password1, host2: password2}
- commands = [
- 'cd ~',
- 'pwd',
- 'whoami'
- ]
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- for host in ips:
- ssh.connect(
- host,
- username=logins[host],
- password=passwords[host],
- key_filename=key_filename)
- stdin, stdout, stderr = ssh.exec_command('; '.join(commands))
- sftp = ssh.open_sftp()
- sftp.get(remote_fname, local_fname) # получить файл с сервера
- sftp.put(local_fname, new_remote_fname) # м загрузить
- ssh.close()
Add Comment
Please, Sign In to add comment