forked from Setzlerte/geniTests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserMachine.py
More file actions
41 lines (28 loc) · 937 Bytes
/
userMachine.py
File metadata and controls
41 lines (28 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import pexpect
os.system("sudo useradd alice")
child = pexpect.spawn("sudo passwd alice")
child.expect("Enter new UNIX password: ")
child.sendline("password")
child.expect("Retype new UNIX password: ")
child.sendline("password")
#os.system("sudo chown -R alice /home/alice")
#os.system("sudo chgrp -R alice /home/alice")
ssh_config_file = open("/etc/ssh/sshd_config", "r")
new_ssh_config_file = open("/etc/ssh/sshd_config_2", "w")
count = 1
ports = []
for line in ssh_config_file:
if count == 54:
new_ssh_config_file.write("PasswordAuthentication yes\n")
elif count == 33:
new_ssh_config_file.write("RSAAuthentication no\n")
elif count == 34:
new_ssh_config_file.write("PubkeyAuthentication no")
else:
new_ssh_config_file.write(line)
count += 1
ssh_config_file.close()
new_ssh_config_file.close()
os.system("sudo mv /etc/ssh/sshd_config_2 /etc/ssh/sshd_config")
os.system("sudo service ssh restart")