CLI Support

This commit is contained in:
best 2019-08-10 16:31:06 -04:00
parent edab0e43d6
commit c9052d8c1f
1 changed files with 6 additions and 3 deletions

View File

@ -2,15 +2,18 @@ from subprocess import call
import os
import random
import string
import click
# Creates a new user
# adduser --disabled-password --gecos "" username
def adduser():
@click.command()
@click.option('--username', help='Specifies a username')
@click.option('--ssh_key', help='Specifies a ssh key')
def adduser(username, ssh_key):
# I used os at this part and will use subprocess at linking to nginx /var/www
print('At the end of this script, new user will be created. ')
username = input('Please enter username.')
print('Username:', username)
ssh_key = input('Please enter ssh public key.')
call(["adduser", "--disabled-password", "-gecos", '''""''', username])
with open("authorized_keys", "w") as keyfile:
keyfile.write(ssh_key)