Skip to content

This script asks you for a username, creates a sudo user with it, allows OpenSSH and activates your Firewall. It also includes a Guide to set up SSH-Authentication. [Tested for 20.04]

Notifications You must be signed in to change notification settings

michael-engelhardt/setup-ubuntu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Initial Setup for Ubuntu Server

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.

How to use

Make sure the Script is Executable

chmod +x setupubuntu.sh

Start the script

./setupubuntu.sh

Delete the Folder

What now?

Setup SSH Authentication

On your local Machine generate an SSH Key and push it via SSH to your server.

Use Powershell

Generate a Key Pair

If you're using Windows, go to C:\Users\YourUser.ssh and:

ssh-keygen

Leave the name as is and set a passphrase.

Transfer to your user

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"

Deactivate Pssword Authentication on your Server

Log into your Server
ssh username@your_server_ip
Disable Password Authentication
sudo nano /etc/ssh/sshd_config

Change the line on the bottom of the file: . . . PasswordAuthentication no . . .

Press Ctrl + X then y then Enter

Restart the sshd service
sudo systemctl restart ssh

Now 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.

About

This script asks you for a username, creates a sudo user with it, allows OpenSSH and activates your Firewall. It also includes a Guide to set up SSH-Authentication. [Tested for 20.04]

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages