def server_customizations():
'''Customize the server (user, authorized_keys, ...).'''
username = env.user
env.user = 'root'
# create user
all_users = run('cut -d: -f1 /etc/passwd').split()
if username not in all_users:
host = env.host
run(flo('adduser {username}'))
# add user to the sudo group, cf. http://askubuntu.com/a/7484
#run('sudo adduser {username} sudo'.format(**locals()))
# http://jeromejaglale.com/doc/unix/ubuntu_sudo_without_password
append('/etc/sudoers', flo('{username} ALL=(ALL) NOPASSWD: ALL'),
use_sudo=True)
# set up password-less login
local(flo('ssh-copy-id -i ~/.ssh/id_rsa.pub {username}@{host}'))
env.user = username
# Disable service apache2 httpd, cf. http://askubuntu.com/a/355102
sudo('update-rc.d apache2 disable')
else:
print(magenta(flo(' nothing to do, user {username} already exists')))
env.user = username
评论列表
文章目录