Created
November 6, 2013 00:45
-
-
Save ramazanpolat/7329013 to your computer and use it in GitHub Desktop.
This script generates linux users which CAN NOT login to shell but CAN change his/her password with SSH."
It is ideal to have those type of users if you are using softwares using OS authentication (eg. IBM DB2)"
This file contains 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
#!/bin/bash | |
if [ $# -eq 0 ] | |
then | |
echo "This script generates linux users which CAN NOT login to shell but CAN change his/her password with SSH." | |
echo "It is ideal to have those type of users if you are using softwares using OS authentication (eg. IBM DB2)" | |
echo "USAGE : $0 {username} " | |
echo " username : prefix of file name to be generated" | |
echo "EXAMPLE:" | |
echo " $0 " | |
echo "Author: Ramazan POLAT - [email protected]" | |
exit 1 | |
fi | |
USERNAME=$1 | |
echo "Adding user : $USERNAME ..." | |
sudo useradd -m -d /home/$USERNAME -s /bin/bash -c "login is forbidden for this user" $USERNAME -N -g users | |
echo "Configuring permissions..." | |
chown root:users /home/$USERNAME | |
chmod 555 /home/$USERNAME | |
echo "trap '' 2" >> /home/$USERNAME/.bash_profile | |
echo "passwd" >> /home/$USERNAME/.bash_profile | |
echo "logout" >> /home/$USERNAME/.bash_profile | |
passwd $USERNAME | |
echo "The user [$USERNAME] created." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment