7 # TODO: a more complete VPS setup
9 # TODO would $EUID be better?
10 if [ "root" != "$(whoami)" ]; then
11 echo "webi adduser: running user is already a non-root user"
16 #apt-get -y install curl wget rsync git
19 # TODO: might there be a better name?
20 # me, this, user, self, person, i, who, do, tron
21 adduser --disabled-password --gecos "" me
22 my_password=$(openssl rand -hex 16)
23 printf "$my_password"'\n'"$my_password" | passwd me
25 # make 'me' a sudo-er (admin)
27 echo "me ALL=(ALL:ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/me
29 # allow users who can already login as 'root' to login as 'me'
30 mkdir -p /home/me/.ssh/
31 chmod 0700 /home/me/.ssh/
32 cp -r "$HOME/.ssh/authorized_keys" /home/me/.ssh/
33 chmod 0600 /home/me/.ssh/authorized_keys
34 chown -R me:me /home/me/.ssh/
36 # ensure that 'me' has an SSH Keypair
37 sudo -i -u me bash -c 'ssh-keygen -b 2048 -t rsa -f /home/me/.ssh/id_rsa -q -N ""'
39 # Install webi for the new 'me' user
40 sudo -i -u me bash -c 'curl -fsSL https://webinstall.dev/webi | bash' \
41 || sudo -i -u me bash -c 'wget -q -O - https://webinstall.dev/webi | bash'
43 # TODO ensure that ssh-password login is off
45 echo "Created user 'me' with password '$my_password'"