Last active
July 11, 2021 00:58
-
-
Save selfagency/9cabb63a72c4e3f486288edd86681a25 to your computer and use it in GitHub Desktop.
[new sudo user + disable root login]
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 | |
# create user | |
adduser --disabled-password --gecos "" selfagency | |
# add to sudo group | |
usermod -aG sudo selfagency | |
# copy over ssh keys | |
rsync --archive --chown=selfagency:selfagency ~/.ssh /home/selfagency | |
# disable password | |
echo "selfagency ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers.d/selfagency | |
# disable root login | |
sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config | |
# just to be sure | |
chown -R selfagency:selfagency /home/selfagency | |
# restart ssh | |
service ssh restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment