Build your own tilde, part II: limits, backups and real people
- Step 7: An account process you can repeat
- Step 10: Backups you’ve actually restored
- Step 11: Keep an eye on the machine
- Step 12: When something goes wrong, suspend, don’t delete
- Step 13: A private preview
- What to add later, and what it really costs
- Before your first public member
In part I we built the skeleton of a tilde: a Debian server you can rescue, SSH that only takes keys, a small firewall, a welcome kit in /etc/skel and pages at /~name/ over HTTPS. Two fake members, Alice and Bob, proved they can’t read each other’s files.
That machine works, but it isn’t ready for people. One member could fill the disk or start a few thousand processes and take everyone down with them. There’s no backup. There’s no calm way to handle a problem. This part fixes that, one step at a time, and ends with a private preview before you open the doors.
Same promise as before: I’ll explain why each step exists, not just what to type.
Step 7: An account process you can repeat
Every account should be created the same way, every time, with a record of who did it. First, decide what you ask people for, and keep it short:
- the username they want
- their public SSH key
- a way to contact them
- a few lines about why they want to join
- that they’ve read and accepted the rules
Don’t ask for a birth date, documents or an address. Data you don’t collect can’t leak. envs.net is a good example of a clear signup form and a published list of what’s allowed, if you want to see how a mature tilde does it.
Do the first ten accounts by hand, with a checklist, so you learn where things break. Then turn the checklist into a small script. Here’s a simple one. Save it as /usr/local/sbin/newmember:
#!/bin/sh
set -eu
user=“$1“
keyfile=“\(2"
case "\)user” in
\[a-z\]*) ;;
*) echo “invalid name”; exit 1 ;;
esac
case “\(user" in
\*MATHPH1XEND\*) echo "invalid name"; exit 1 ;;
esac
test "\){#user}” -ge 3 && test “\({#user}" -le 16 || { echo "invalid name"; exit 1; }
if grep -qx "\)user” /etc/tilde/reserved-names 2>/dev/null; then echo “reserved name”; exit 1; fi
if id “\(user" >/dev/null 2>&1; then echo "user exists"; exit 1; fi
ssh-keygen -l -f "\)keyfile” >/dev/null || { echo “invalid key”; exit 1; }
adduser –disabled-password –comment “” “\(user"
usermod -aG pubnix "\)user”
install -m 600 -o “\(user" -g "\)user” “\(keyfile" "/home/\)user/.ssh/authorized_keys”
setquota -u “\(user" 1000000 1200000 20000 25000 /
echo "\)(date -Iseconds) created $user by \({SUDO\_USER:-root}" >> /var/log/tilde-accounts.log
Make it executable with
Write a comment