Advertisement
geofferey

[BASH] - Writing User Input/Variable Val to File - [Example]

Oct 23rd, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.66 KB | None | 0 0
  1. #!/system/xbin/bash
  2. echo "---CONFIGURE-SSH-DAEMON---"
  3.  
  4. echo ""
  5.  
  6. read -s -p "Enter new password:" NEWPASS
  7. echo ""
  8.  
  9. while [[ -z "$NEWPASS" ]]; do
  10. echo ""
  11. echo "Password CAN NOT be blank"
  12. echo ""
  13. read -s -p "Enter new password:" NEWPASS;
  14. echo ""
  15. done
  16.  
  17. sed -i -e"s/^PASS=.*/PASS=$NEWPASS/" /etc/sshd.conf
  18.  
  19. if test $? -eq 0; then
  20. echo 'password written'
  21. else
  22. echo 'write attempt failed!'
  23. fi
  24.  
  25. echo ""
  26.  
  27. read -p "Enter new port: " NEWPORT
  28.  
  29. if test "$NEWPORT" = ""; then
  30. echo "DEFAULT PORT #2222"; sed -i -e"s/^PORT=.*/PORT=2222/" /etc/sshd.conf
  31. else
  32. sed -i -e"s/^PORT=.*/PORT=$NEWPORT/" /etc/sshd.conf
  33. fi
  34.  
  35. if test $? -eq 0; then
  36. echo "port set"
  37. else
  38. echo "write attempt failed!"
  39. fi
  40.  
  41. echo ""
  42.  
  43. if [[ $(find /data/data/br.com.bott.droidsshd/files/etc/ -name "dropbear_rsa_host_key") ]]; then
  44. echo "Should we remove old key(s)?";
  45. echo "";
  46. rm -i /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_rsa_host_key;
  47. echo "";
  48. rm -i /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_dss_host_key
  49. fi
  50.  
  51. echo ""
  52.  
  53. echo "---GENERATING-RSA-KEY---"; dropbearkey -t rsa -f /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_rsa_host_key; chmod 400 /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_rsa_host_key
  54.  
  55. echo ""
  56.  
  57. echo "---GENERATING-DSS-KEY---"; dropbearkey -t dss -f /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_dss_host_key; chmod 400 /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_dss_host_key
  58.  
  59. echo ""; echo "Restarting dropbear with new settings..."
  60.  
  61. killall dropbear
  62.  
  63. echo ""
  64.  
  65. dropbear
  66.  
  67. echo ""
  68.  
  69. echo ""; echo "Press RETURN to continue"; read return; clear
  70.  
  71. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement