Created
March 6, 2019 06:50
-
-
Save pinfort/2464fd2d7d5729ba2b95073c2e75c77e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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