Skip to content

Instantly share code, notes, and snippets.

@syshack
Created June 29, 2012 05:57
Show Gist options
  • Select an option

  • Save syshack/3016113 to your computer and use it in GitHub Desktop.

Select an option

Save syshack/3016113 to your computer and use it in GitHub Desktop.
sshcmd
import paramiko as ssh
port=22
username='xxx'
passwd='xxx'
def SshCmd(cmd):
s=ssh.SSHClient()
s.set_missing_host_key_policy(ssh.AutoAddPolicy())
s.connect(host,port,username,passwd)
stdin,stdout,stderror =s.exec_command(cmd)
print stdout.read()
s.close
if __name__ == '__main__':
f=open('ip.lst','r')
hosts=f.readlines()
for host in hosts:
SshCmd('ls -al')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment