#!/bin/bash
# Default command anyterm will run.
# Simply prompt the user for a username and
# ssh locally as that user
while : ; do
echo -n "Username: "
read U
# Make sure it does not start with a "-" and only contains valid
# username characters.
if [[ "$U" =~ "^[A-Za-z0-9_][A-Za-z0-9_-]*\$" ]]; then
ssh "$U@localhost"
else
echo "Bad username."
fi
done