ao-mud is a spellbook of well-commented atomic bash scripts that each do one thing. we are building semantic building blocks for an autonomously-evolving digital spellcasting language.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1019 B

#!/bin/sh
# This script creates a new player in the MUD and associates them with an SSH key.
# It first prompts the user for a player name and an SSH key.
# It then checks if a user with that player name and SSH key already exists, and if so, exits.
# If the user and key combination do not already exist, it adds the key to the authorized_keys file and creates the corresponding user.
echo "Enter player name:"
read playername
echo "Enter SSH key:"
read sshkey
# check if user already exists
if id "$playername" >/dev/null 2>&1; then
echo "Error: user $playername already exists. Please delete the existing user first and try again."
exit 1
fi
# check if key already exists in authorized_keys file
if grep -q "$sshkey" ~/.ssh/authorized_keys; then
echo "Error: key already exists in authorized_keys file. Please delete the existing key first and try again."
exit 1
fi
# add key to authorized_keys file
echo "$sshkey $playername@mud" >> ~/.ssh/authorized_keys
# create user
useradd "$playername"