Advertisement
Guest User

Untitled

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