Skip to content

Instantly share code, notes, and snippets.

@pinfort
Created March 6, 2019 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinfort/2464fd2d7d5729ba2b95073c2e75c77e to your computer and use it in GitHub Desktop.
Save pinfort/2464fd2d7d5729ba2b95073c2e75c77e to your computer and use it in GitHub Desktop.
# -*- coding: utf8 -*-
import os
import time
username = raw_input("input new user name\n>>")
os.system("useradd %s" % unicode(username))
os.system("passwd %s" % unicode(username))
os.system("chmod 701 /home/%s" % unicode(username))
os.system("mkdir /home/%s/.ssh" % unicode(username))
os.system("chmod 700 /home/%s/.ssh" % (unicode(username),))
os.system("chown %s:%s /home/%s/.ssh" % (unicode(username), unicode(username), unicode(username)))
os.system("vi /home/%s/.ssh/authorized_keys" % (unicode(username),))
os.system("chmod 600 /home/%s/.ssh/authorized_keys" % (unicode(username),))
os.system("chown %s:%s /home/%s/.ssh/authorized_keys" % (unicode(username), unicode(username), unicode(username)))
print "please change setting password authentication -> no"
time.sleep(2)
os.system("vi /etc/ssh/sshd_config")
os.system('usermod -aG wheel ' + username)
print "ssh setting finished."
# sudo apt-get install openssh-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment