@task
@log_call
@hosts([(u'root@%s' % host) for host in env.hosts])
def secure(new_user=env.user):
 run(u'apt-get update -q')
 run(u'apt-get upgrade -y -q')
 run((u"adduser --gecos '' %s" % new_user))
 run((u'usermod -G sudo %s' % new_user))
 run(u"sed -i 's:RootLogin yes:RootLogin no:' /etc/ssh/sshd_config")
 run(u'service ssh restart')
 print(green((u"Security steps completed. Log in to the server as '%s' from now on." % new_user), bold=True))

@ task @ log_call @ hosts ( [ ( u'root@%s' % host ) for host in env . hosts ] ) def secure ( new_user = env . user ) : run ( u'apt-get update -q' ) run ( u'apt-get upgrade -y -q' ) run ( ( u"adduser --gecos '' %s" % new_user ) ) run ( ( u'usermod -G sudo %s' % new_user ) ) run ( u"sed -i 's:RootLogin yes:RootLogin no:' /etc/ssh/sshd_config" ) run ( u'service ssh restart' ) print ( green ( ( u"Security steps completed. Log in to the server as '%s' from now on." % new_user ) , bold = True ) )
minimal security steps for brand new servers .