Advertisement
Guest User

Untitled

a guest
Mar 15th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #####################################################
  2. # Change settings here!!!
  3. #####################################################
  4. username="changeme"
  5. sshport="54814" # <-- change to random high port!
  6. #####################################################
  7.  
  8. # get the password from the command line
  9. read clearpass
  10.  
  11. # determine home folder
  12. homefolder=`eval echo "~$username"`
  13.  
  14. # set locale
  15. locale-gen en_US en_US.UTF-8 hu_HU hu_HU.UTF-8
  16. dpkg-reconfigure locales
  17.  
  18. # calculate password for useradd and add the user
  19. pwsalt=`perl -e 'printf "%08X", rand(0xffffffff)'`
  20. password=`perl -e 'printf "%s", crypt($ARGV[0], "\\$6\\$$ARGV[1]\\$")' $clearpass $pwsalt`
  21. useradd -m -p $password -s /bin/bash $username
  22.  
  23. # move the dnet data dir to new user (if it exists)
  24. if [ -d /root/.darknet ]; then
  25. # stop the masternode in case it is running
  26. /root/darknet-cli stop
  27. mv /root/.darknet $homefolder
  28. fi
  29.  
  30. # move the dnet executables to the user's home dir
  31. mv /root/darknet* $homefolder
  32.  
  33. # remove apache -- it's not needed
  34. service apache2 stop
  35. apt-get remove apache2*
  36.  
  37. # add our user to sudoers
  38. sed -i.bak s/sudo:x:27:/sudo:x:27:$username/ /etc/group
  39.  
  40. # disallow root login via ssh and change port
  41. sed -i.bak s/PermitRootLogin yes/PermintRootLogin no/ /etc/ssh/sshd_config
  42. sed s/Port 22/Port $sshport/ /etc/ssh/sshd_config
  43. service ssh restart
  44.  
  45. # don't keep a history file because they are security problem
  46. echo "HISTFILE=/dev/null" >> $homefolder/.profile
  47.  
  48. # change all ownership
  49. chown -R $username:$username $homefolder
  50.  
  51. # indicate success
  52. echo Sucessful Termination. Don\'t forget to test login remotely with:
  53. echo
  54. echo ssh -p $sshport $username@`ip route get 8.8.8.8 | awk '{print $NF; exit}'`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement