From e97a2b17f3592f03af5fcef283e04e75156a5e08 Mon Sep 17 00:00:00 2001 From: khuxkm Date: Fri, 21 Sep 2018 10:04:48 -0400 Subject: [PATCH] Add work --- email.tmpl | 43 +++++++++++++++++++++++++++++++++++++++++++ makeuser | 11 +++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 email.tmpl diff --git a/email.tmpl b/email.tmpl new file mode 100644 index 0000000..2c07303 --- /dev/null +++ b/email.tmpl @@ -0,0 +1,43 @@ +Subject: welcome to tilde.team! + +hey ~newusername, + +welcome to tilde.team! + +your new account has been established. you can ssh into tilde.team with +the ssh key you supplied on registration. + +your password is "newpassword". please change it when you log in for +the first time. the password is used for imap/smtp auth, not shell login, +which is set to only use ssh key authentication. + +to get started, type `motd` at the command prompt to see a few ways to +get started. have fun! + +the greatest value of tilde.team is not the services provided by the +server, but rather the interesting and welcoming community built by its +users. this is possible because of people like you who choose to make +this a great place. the best way you can help tilde.team is by working +to support a great system culture. chat on irc; build cool programs and +share them with others; focus on learning, and help others learn; be a +good example for others; have fun! + +also, your ~/public_html directory is served at +https://tilde.team/~newusername/ +(you can also use https://newusername.tilde.team) + +check out our wiki at https://tilde.team/wiki/ for more information (and +maybe help us write a new wiki article:) + +our irc is tilde.chat, an irc network connecting several +tilde servers. the `chat` command on your ~team shell will open up +weechat with some nice default configs and plugins. +see our wiki article (https://tilde.team/wiki/?page=irc) +or https://tilde.chat site for information on how to connect from elsewhere. +we also have a webclient at https://irc.tilde.team that you can +register for by running the `webirc` command from a shell session. + +we look forward to seeing you around! welcome to the ~team! + +~tilde.team admins + diff --git a/makeuser b/makeuser index 6ab69fb..d8e39fc 100755 --- a/makeuser +++ b/makeuser @@ -1,6 +1,8 @@ #!/usr/bin/python3 -import os,argparse +import subprocess,argparse,random,string +from ctypes import cdll,c_char_p +libc = cdll.LoadLibrary("libc.so.6") parser = argparse.ArgumentParser(prog="makeuser",description="A user adding script.") parser.add_argument("username",help="Username of user.") @@ -8,4 +10,9 @@ parser.add_argument("email",help="Email of user.") parser.add_argument("key",help="The user's SSH pubkey.") args = parser.parse_args() -print(args.username,args.email,args.key) +pw = "".join(random.sample(string.ascii_letters+string.digits,20)) +cr = libc.crypt(pw) + +subprocess.run("sudo useradd -m -g 100 -p {} -s /bin/bash {}".format(cr,args.user) +subprocess.run("echo '{}' | sudo tee /home/{}/.ssh/authorized_keys".format(args.key,args.user)) +subprocess.run("sed -e 's/username/{}/' -e 's/password/{}/' email.tmpl | sendmail {} sudoers@tilde.team")