Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import paramiko
- servers = {}
- config = open('/home/polichnoy/param.test').read().split('\n')
- for i in config:
- if len(i) > 0:
- i = i.split()
- servers[i[0]] = i[1]
- def ssh_conn(host, user, secret, port, value):
- client = paramiko.SSHClient()
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(hostname=host, username=user, password=secret, port=port)
- stdin, stdout, stderr = client.exec_command("echo '%s' > /home/polichnoy/hostname" % (value))
- stdin, stdout, stderr = client.exec_command("echo '%s' > /home/polichnoy/hostname1" % (value))
- data = stdout.read() + stderr.read()
- client.close()
- print data
- for i in servers:
- ssh_conn(i, 'polichnoy', '111111', 22, servers[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement