瀏覽代碼

Generate a random initial password for images

Bob Mottram 9 年之前
父節點
當前提交
a4aca5ddbc
共有 1 個檔案被更改,包括 21 行新增5 行删除
  1. 21
    5
      src/freedombone-image-customise

+ 21
- 5
src/freedombone-image-customise 查看文件

@@ -199,12 +199,28 @@ create_generic_image() {
199 199
 # initial setup of the system
200 200
 if [ -f ~/.initial_setup ]; then
201 201
     clear
202
-    echo '>>> Freedombone system initial setup <<<'
202
+    echo "
203
+ .---.                  .              .
204
+ |                      |              |
205
+ |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
206
+ |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
207
+ '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
208
+
209
+                   Initial setup process
210
+"
211
+    echo 'This is your new password. Use whenever you wish to ssh into'
212
+    echo 'this system.'
213
+    echo ''
214
+
215
+    NEW_USER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"
216
+    echo "${USER}:${NEW_USER_PASSWORD}"|chpasswd
217
+    echo "    $NEW_USER_PASSWORD"
218
+
219
+    echo ''
220
+    echo 'Copy it into a password manager or write it down somewhere.'
203 221
     echo ''
204
-    echo 'The first thing you need to do is to change your password, otherwise'
205
-    echo 'your system will be insecure. Your password should be at least 10'
206
-    echo 'characters long and contain letters and numbers. Do this now:'
207
-    passwd
222
+    read -n1 -r -p "Press any key to continue..." key
223
+
208 224
     rm ~/.initial_setup
209 225
     sudo su
210 226
 fi