User create on RHEL systems
# cat createuser.sh
#!/bin/bash
# Create user and grant previledge access
# add user jay with wheel group. wheel group has special root like permission.
useradd -mG wheel jay
# assign password to jay user
echo "Passw0rd!" | passwd jay --stdin
# Propmpt for password
sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config
# Allow user to run commmand without password. be careful
sed -i "s/%wheel\tALL=(ALL)\tALL/# %wheel\tALL=(ALL)\tALL/g" /etc/sudoers
sed -i "s/# %wheel\tALL=(ALL)\tNOPASSWD: ALL/%wheel\tALL=(ALL)\tNOPASSWD: ALL/g" /etc/sudoers
Restart sshd service since we modify the config
systemctl restart sshd
No comments:
Post a Comment