Last active
January 21, 2019 08:32
-
-
Save ledongthuc/6f888e019ebb3c324bf150f89e767dd2 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
# PLEASE REPLACE <username>, <public_key>, <admin_user> | |
# Add new user with sudo admin | |
useradd -m -d /home/<username> -s /bin/bash <username> | |
mkdir -p '/home/<username>/.ssh/' | |
touch /home/<username>/.ssh/authorized_keys | |
echo -n "<public_key>" >> /home/<username>/.ssh/authorized_keys | |
chown -R <username>:<username> /home/<username>/.ssh | |
chmod 700 /home/<username>/.ssh | |
chmod 600 /home/<username>/.ssh/authorized_keys | |
usermod -aG wheel <username> | |
# Sudo without password | |
# visudo | |
%wheel ALL = (ALL) NOPASSWD: ALL | |
# Sudo su - another user without password | |
# visudo | |
<user1> ALL = (root) NOPASSWD: /bin/su - <admin_user> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment