2019-07-16 00:28:24 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-07-16 17:55:52 +00:00
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo 'usage: makeitso <primaryusername>' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-07-16 16:59:50 +00:00
|
|
|
if [ ! -d /home/authorizedkeysuser ]; then
|
|
|
|
#sudo adduser --disabled-login --gecos 'User for AuthorizedKeysCommand' authorizedkeysuser ||
|
|
|
|
sudo useradd -c 'User for AuthorizedKeysCommand' -d /home/authorizedkeysuser -m -s/usr/sbin/nologin authorizedkeysuser
|
|
|
|
fi
|
2019-07-16 00:28:24 +00:00
|
|
|
|
2021-07-16 17:05:29 +00:00
|
|
|
grep -qF 'AuthorizedKeysCommand /etc/ssh/get_authorized_keys' /etc/ssh/sshd_config || \
|
2019-07-16 17:55:52 +00:00
|
|
|
sudo sh -c "echo 'Match User $1
|
|
|
|
AuthorizedKeysCommand /etc/ssh/get_authorized_keys
|
|
|
|
AuthorizedKeysCommandUser authorizedkeysuser' >> /etc/ssh/sshd_config"
|
2019-07-16 00:28:24 +00:00
|
|
|
|
2019-07-29 15:05:05 +00:00
|
|
|
sudo cp get_authorized_keys /etc/ssh
|
2019-07-16 00:28:24 +00:00
|
|
|
|
|
|
|
sudo chmod 755 /etc/ssh/get_authorized_keys
|
|
|
|
|
|
|
|
sudo systemctl restart sshd
|