Last active
August 29, 2019 17:22
-
-
Save yigitozkavci/8d452ddca5b8be18db0b9e16107c03e7 to your computer and use it in GitHub Desktop.
Unrootify yourself in a newly created ubuntu instance
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
export USERNAME=yigit | |
echo -e "\n\nAllowUsers root $USERNAME" >> /etc/ssh/sshd_config | |
sudo service ssh restart | |
mkdir -p /home/$USERNAME/.ssh | |
cp /root/.ssh/authorized_keys /home/$USERNAME/.ssh | |
sudo adduser $USERNAME | |
sudo adduser $USERNAME sudo | |
sudo chown -R $USERNAME /home/$USERNAME | |
# To make this user a ssh user | |
sudo chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh | |
sudo chmod 0700 /home/$USERNAME/.ssh | |
sudo chmod 0600 /home/$USERNAME/.ssh/authorized_keys | |
service ssh reload | |
# To add user to sudoers | |
usermod -aG sudo $USERNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment