wrap with block
authorAJ ONeal <aj@therootcompany.com>
Thu, 25 Jun 2020 02:46:14 +0000 (02:46 +0000)
committerAJ ONeal <aj@therootcompany.com>
Thu, 25 Jun 2020 02:46:14 +0000 (02:46 +0000)
ssh-utils/ssh-adduser.sh
ssh-utils/ssh-pubkey.sh
ssh-utils/ssh-setpass.sh

index 6400a0c4f75efba196ca48b5fd878af73b1cb1e2..beb449297996d9ea3cc37020eb6a655eaef7d56f 100644 (file)
@@ -1,37 +1,39 @@
 #!/bin/bash
 
-set -e
-set -u
-
-# TODO: a more complete VPS setup
-
-# TODO would $EUID be better?
-if [ "root" != "$(whoami)" ]; then
-  echo "webi adduser: running user is already a non-root user"
-  exit 0
-fi
-
-#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
-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 me:me /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'
-
-# TODO ensure that ssh-password login is off
-
-echo "Created user 'me' with password '$my_password'"
+{
+    set -e
+    set -u
+
+    # TODO: a more complete VPS setup
+
+    # TODO would $EUID be better?
+    if [ "root" != "$(whoami)" ]; then
+      echo "webi adduser: running user is already a non-root user"
+      exit 0
+    fi
+
+    #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
+    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 me:me /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'
+
+    # TODO ensure that ssh-password login is off
+
+    echo "Created user 'me' with password '$my_password'"
+}
index 044e1e11667b243cad6bd9f71581346028cd2e4f..9f0722911b6ee68640012814bf885f2b60aa580b 100644 (file)
@@ -1,25 +1,27 @@
 #!/bin/bash
 
-set -e
-set -u
+{
+    set -e
+    set -u
 
-mkdir -p "$HOME/.ssh/"
+    mkdir -p "$HOME/.ssh/"
 
-if [ ! -f "$HOME/.ssh/id_rsa" ]; then
-    ssh-keygen -b 2048 -t rsa -f "$HOME/.ssh/id_rsa" -q -N ""
-    echo ""
-fi
+    if [ ! -f "$HOME/.ssh/id_rsa" ]; then
+        ssh-keygen -b 2048 -t rsa -f "$HOME/.ssh/id_rsa" -q -N ""
+        echo ""
+    fi
 
-if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then
-    ssh-keygen -y -f "$HOME/.ssh/id_rsa" > "$HOME/.ssh/id_rsa.pub"
-    echo ""
-fi
+    if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then
+        ssh-keygen -y -f "$HOME/.ssh/id_rsa" > "$HOME/.ssh/id_rsa.pub"
+        echo ""
+    fi
 
-# TODO use the comment (if any) for the name of the file
-echo ""
-echo "~/Downloads/id_rsa.$(whoami).pub":
-echo ""
-rm -f "$HOME/Downloads/id_rsa.$(whoami).pub":
-cp -r "$HOME/.ssh/id_rsa.pub" "$HOME/Downloads/id_rsa.$(whoami).pub"
-cat "$HOME/Downloads/id_rsa.$(whoami).pub"
-echo ""
+    # TODO use the comment (if any) for the name of the file
+    echo ""
+    echo "~/Downloads/id_rsa.$(whoami).pub":
+    echo ""
+    rm -f "$HOME/Downloads/id_rsa.$(whoami).pub":
+    cp -r "$HOME/.ssh/id_rsa.pub" "$HOME/Downloads/id_rsa.$(whoami).pub"
+    cat "$HOME/Downloads/id_rsa.$(whoami).pub"
+    echo ""
+}
index 014b68a4c13ffcecd41197d18cd4df117e49c7e2..4d399cd98fec5ab5573ac8b9789133bed4f7c201 100644 (file)
@@ -1,6 +1,8 @@
 #!/bin/bash
 
-set -e
-set -u
+{
+    set -e
+    set -u
 
-ssh-keygen -p -f "$HOME/.ssh/id_rsa"
+    ssh-keygen -p -f "$HOME/.ssh/id_rsa"
+}