-
-
Save nils-wagner-signavio/83e6e4bbfe422bbf5e4fd76839270dcb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# normally first char of prename + surname | |
users="${@:-nwagner}" | |
# normally users | |
group="users" | |
# normally adm and/or sudo | |
groups="adm,sudo" | |
for user in ${users}; do | |
auth_keys_file=/home/${user}/.ssh/authorized_keys | |
echo "Creating access for user: ${user}" | |
useradd -s /bin/bash -m ${user} -g ${group} -G ${groups} -c "manually created on $(date +%Y%m%d-%H%M%S)" | |
mkdir -m 0700 /home/${user}/.ssh | |
[ -f "${auth_keys_file}" ] || install -b -m 0600 /dev/null ${auth_keys_file} | |
echo "Paste user's SSH pub key here, make sure to end with new line and press CTRL+D to exit" | |
echo ${auth_keys_file} | |
cat >>${auth_keys_file} | |
echo "SSH pub key stored in ${auth_keys_file}" | |
chown -R ${user}:${group} $(dirname ${auth_keys_file}) | |
echo -e "... User '${user}' done\n" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alessandro
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCKnVZlFYK8LqkgWKX0ON6WqrSYMNpjh0IBA8VE7uq9QHqHREd9vIuKbxCXKwThWCrSKjlSkwT/OrYiHxQxUde3WxXPuM5wZb6zSHpepvfBuF8ASzZZMG8MNm8b+RZ45wrJiFeGB4sId7H4xEbujQwfdYN78UqSWxjI02VP1SA0DX+k8INCHxTb0c8QIcAgmKalep8IBBQjHV4HbmK3XPa03uIaQlpfjcNiAbEU9qzs2ho3z53XuMlzOzHQdxr5dAaWGSzhvxPHy9662fPQHz7+mkBo+mAjziPsO/JGhbofO+x+pRW1dXB/BUA6amTqHFozMRE9Co7VZPaG1vbhAMXTelHSz2D89T4zgiGYyqOjHPAdgFhi0DgBgro8kaG/QnHrkWRUFHSUDbQinEe/DA8S2Z21xGT5B/dFwhWqmYhw3vX52VZjHsKAWq6bCxLaGoBqtk55bXTzq+NAKovUTa5Ii525l4ScsOnLIrjIyuuxCQhT12nQhL5lIfFLSBA9aNB02DgUm2rkRzmPX8wTMstCwYAN6Oxv6SFjfYAklGpAXZtqfnjb0gxDCKwAeUP1F9iRmxtRmxRyGXSvrsSSgStYzqQtTHN/e6qQt7rcjne9rGcaoJ08gIXgahvUgdz27vmGaqpeUdZ/lnHz/g012rAS7NAbQwb5MRMd3dK82Mamw== [email protected]