This Bash Script will
- Create a Superuser for you
- Add the user to the sudo group
- Allow SSH Connections in Firewall
- Activate the Firewall
At the bottom of this Readme you can follow the steps to activate SSH-Key Authentication.
chmod +x setupubuntu.sh./setupubuntu.shOn your local Machine generate an SSH Key and push it via SSH to your server.
Use Powershell
If you're using Windows, go to C:\Users\YourUser.ssh and:
ssh-keygenLeave the name as is and set a passphrase.
Change the IP and the username.
cat ~/.ssh/id_rsa.pub | ssh username@your_server_ip "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"
ssh username@your_server_ipsudo nano /etc/ssh/sshd_configChange the line on the bottom of the file: . . . PasswordAuthentication no . . .
Press Ctrl + X then y then Enter
sudo systemctl restart sshNow test if it works before you close your Terminal!
Consider Also to change the PermitRootLogin to no inside the /etc/ssh/sshd_config file, to add more security.