-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenVPN_automation
More file actions
60 lines (56 loc) · 1.81 KB
/
Copy pathOpenVPN_automation
File metadata and controls
60 lines (56 loc) · 1.81 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Script will get number of clients to create list, then their city and names.
# After it'll be iterating them and create certificates, keys, and passwords
import pexpect
import os
import random
print('Please, enter a number of the persons: ')
num = int(input())
print('Please, enter a city: ')
city = input()
print("Please, enter their names: ")
persons = list(input() for i in range(num))
# Chars for the password generator
chars = '+-/*!&$#?=@<>abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
# the iteration for every object in generated list
for p in persons:
pochta = p[0:-2].lower() + '@domain.ru'
com = './build-key ' + p
gen = pexpect.spawn(com)
gen.expect('RU')
gen.sendline('RU')
gen.expect('full name')
gen.sendline(city)
gen.expect('eg, city')
gen.sendline(city)
gen.expect('eg, company')
gen.sendline('Company')
gen.expect('eg, section')
gen.sendline('Company')
gen.expect('eg, your name or your server')
gen.sendline(p)
gen.expect('EasyRSA')
gen.sendline('EasyRSA')
gen.expect('Address')
gen.sendline(pochta)
gen.expect('challenge password')
gen.sendline('strong_password')
gen.expect('company name')
gen.sendline('Company')
gen.expect('the certificate')
gen.sendline('y')
gen.expect('certificate requests certified')
gen.sendline('y')
password = ''
# Password generating;
for n in range(12):
password += random.choice(chars)
comPass1 = 'echo "'
comPass2 = '" >> /path/user.pass'
comPass = comPass1 + p + ':' + password + comPass2
os.system(comPass)
# Moving new keys and crts to the upload directory
cp1 = 'cp /path/' + p +'.crt /path/'
cp2 = 'cp /path/' + p +'.key /path/'
os.system(cp1)
os.system(cp2)
print('Password for ' + p + ': ' + password)