Skip to content

Instantly share code, notes, and snippets.

@BirknerAlex
Created November 3, 2021 16:22
Show Gist options
  • Save BirknerAlex/e6b3277a15007ba07878cc9211d28251 to your computer and use it in GitHub Desktop.
Save BirknerAlex/e6b3277a15007ba07878cc9211d28251 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ -d "/home/ubuntu/.ssh/" ]]; then
mv -v /home/ubuntu/.ssh/ /root/
chown -R root:root /root/.ssh/ && chmod 700 /root/.ssh/ && chmod 600 /root/.ssh/*
sed -ie 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
systemctl reload ssh
pkill -u ubuntu && userdel -r ubuntu
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment