use WEBI_HOST rather than webinstall.dev
[webi-installers/.git] / ssh-utils / ssh-adduser.sh
index 250cc7e737608bd358baa7c3676b454b3c98a86c..27c6dc89147fb66c3e3317e5bbb3fbf85985274f 100644 (file)
     #apt-get -y update
     #apt-get -y install curl wget rsync git
 
-    # Add User
-    # TODO: might there be a better name?
-    # me, this, user, self, person, i, who, do, tron
-    adduser --disabled-password --gecos "" me
+    # Add User app
+    # Picking 'app' because that seems to be what the # Docker/Vagrant
+    # crowd is doing. TODO: Other ideas? me, user, tron
+    adduser --disabled-password --gecos "" app
     my_password=$(openssl rand -hex 16)
-    printf "$my_password"'\n'"$my_password" | passwd me
-    adduser me sudo
-    echo "me ALL=(ALL:ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/me
-    sudo -i -u me bash -c 'ssh-keygen -b 2048 -t rsa -f /home/me/.ssh/id_rsa -q -N ""'
-    mkdir -p /home/me/.ssh/
-    cp -r $HOME/.ssh/authorized_keys /home/me/.ssh/
-    chmod 0600 /home/me/.ssh/authorized_keys
-    chown -R me:me /home/me/.ssh/
-
-    # Install webi for the new user
-    sudo -i -u me bash -c 'curl -fsSL https://webinstall.dev/webi | bash' \
-        || sudo -i -u me bash -c 'wget -q -O - https://webinstall.dev/webi | bash'
+    printf "$my_password"'\n'"$my_password" | passwd app
+
+    # make 'app' a sudo-er (admin)
+    adduser app sudo
+    echo "app ALL=(ALL:ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/app
+
+    # allow users who can already login as 'root' to login as 'app'
+    mkdir -p /home/app/.ssh/
+    chmod 0700 /home/app/.ssh/
+    cp -r "$HOME/.ssh/authorized_keys" /home/app/.ssh/
+    chmod 0600 /home/app/.ssh/authorized_keys
+    touch /home/app/.ssh/config
+    chmod 0644 /home/app/.ssh/config
+    chown -R app:app /home/app/.ssh/
+
+    # ensure that 'app' has an SSH Keypair
+    sudo -i -u app bash -c 'ssh-keygen -b 2048 -t rsa -f /home/app/.ssh/id_rsa -q -N ""'
+
+    # Install webi for the new 'app' user
+    WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
+    sudo -i -u app bash -c "curl -fsSL '$WEBI_HOST/webi' | bash" \
+        || sudo -i -u app bash -c "wget -q -O - '$WEBI_HOST/webi' | bash"
 
     # TODO ensure that ssh-password login is off
 
-    echo "Created user 'me' with password '$my_password'"
+    echo "Created user 'app' with password '$my_password'"
 }