Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.1.1.1
- 2.2.2.2
- 10.10.10.10
- sdasd
- adsadsada
- adgfefwef
- #!/bin/env python
- import pexpect
- import sys
- import time
- username = raw_input("User: ")
- password = "AMpt157B"
- adduser = "set account name " + username
- f = open('file_hosts')
- for line in f:
- string = line.replace("n","")
- if len(username) > 0:
- #login
- login = "ssh -o "ConnectTimeout=2" -o "StrictHostKeyChecking no" admin@"+string
- child = pexpect.spawn (login)
- child.logfile = open("mylog", "a")
- i = child.expect([pexpect.EOF, '[Pp]assword: '])
- if i == 0:
- print 'No SSH connection for or invalid IP - %s' % (string)
- if i == 1:
- child.sendline ('file_passwd')
- child.expect ('admin:')
- child.sendline(adduser)
- k = child.expect(['Account name already exists', 'Please enter the privilege level :'])
- if k == 0:
- print 'User %s already exists - %s' % (username,string)
- if k == 1:
- child.sendline('1')
- child.expect ('Please enter the password :')
- child.sendline(password)
- child.expect ('re-enter to confirm :')
- child.sendline(password)
- child.expect ('admin:')
- child.sendline('exit')
- print "Username %s was successfuly create in %s" % (username,string)
- else:
- print "Your input is empty...TRY AGAIN"
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement