anyterm/anyterm-cmd
2012-05-22 13:20:22 +02:00

22 lines
483 B
Bash

#!/bin/bash
# Default command anyterm will run.
# Simply prompt the user for a username and
# ssh locally as that user
set -eo pipefail
while : ; do
echo -n "Username: "
read U
if [[ -z "$U" ]]; then
echo "Disconnecting."
exit
fi
# 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.localdomain" || :
else
echo "Bad username."
fi
done