Skip to content

Instantly share code, notes, and snippets.

@clayrisser
Last active March 31, 2026 05:19
Show Gist options
  • Select an option

  • Save clayrisser/6cf285958c0a1e959a501621ea1304b3 to your computer and use it in GitHub Desktop.

Select an option

Save clayrisser/6cf285958c0a1e959a501621ea1304b3 to your computer and use it in GitHub Desktop.
root2admin
#!/bin/sh
sudo adduser --disabled-password --gecos "Admin" admin
sudo usermod -aG sudo admin
echo "admin ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/admin
sudo chmod 440 /etc/sudoers.d/admin
sudo -u admin ssh-keygen -t ed25519 -f /home/admin/.ssh/id_ed25519 -N ""
sudo cp /root/.ssh/authorized_keys /home/admin/.ssh/authorized_keys
sudo chown -R admin:admin /home/admin/.ssh
sudo chmod 600 /home/admin/.ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment