Wednesday, March 10, 2021

RHEL - User create on RHEL systems

 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

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...