alpine.sh 970 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. PASS="${1:-Vicer}"
  3. PORT="${2:-22}"
  4. [ `whoami` == "root" ] || exit 1
  5. echo "remote" >/etc/hostname
  6. echo "root:${PASS}" |chpasswd root
  7. sed -i "s/^#\?Port.*/Port $PORT/g" /etc/ssh/sshd_config;
  8. sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
  9. sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
  10. sed -i 's/^#\?KbdInteractiveAuthentication.*/KbdInteractiveAuthentication no/g' /etc/ssh/sshd_config;
  11. [ -d /etc/ssh/sshd_config.d ] && rm -rf /etc/ssh/sshd_config.d/*
  12. systemctl restart sshd 2>/dev/null || /etc/init.d/sshd restart
  13. [ -e /usr/share/zoneinfo/Asia/Shanghai ] && {
  14. cp -rf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  15. echo "Asia/Shanghai" > /etc/timezone
  16. }
  17. for usr in `cat /etc/passwd |cut -d':' -f1,6`; do
  18. u=`echo "$usr" |cut -d':' -f1`
  19. h=`echo "$usr" |cut -d':' -f2`
  20. echo "$h" |grep -q '^/home' && {
  21. deluser "$u" 2>/dev/null
  22. rm -rf "$h" 2>/dev/null
  23. }
  24. done
  25. exit 0