tildeblack-ops/restore.sh

18 lines
433 B
Bash
Executable File

#!/bin/sh
key="$1"
users="$*"
if [ -n "$key" ] && [ -n "$users" ]; then
for n in $users; do
if [ -s "/home/${n}/.ssh/authorized_keys" ]; then
if grep -q "DISABLED" "/home/${n}/.ssh/authorized_keys"; then
if [ "$n" != "fox" ]; then
printf "%s\\n" "$key" > "/home/${n}/.ssh/authorized_keys"
printf "%s restored\\n" "$n"
usermod -s /bin/ksh "${n}"
fi
fi
fi
done
fi