Initial Server Setup with Ubuntu 18.04
Initial Server Setup with Ubuntu 18.04
In this tutorial, we will guide you through the steps to set up your Ubuntu 18.04 server for the first time. These steps are important for securing your server and ensuring that it is ready for use.
Step 1: Logging in and Updating the System
The first step is to log in to your server using SSH. Once logged in, update the system by running the following command:
sudo apt update && sudo apt upgrade
Step 2: Creating a New User and Giving Sudo Access
It is recommended to create a new user for security purposes. To do so, run the following command:
sudo adduser newuser
Replace "newuser" with the username you want to create.
Next, give the new user sudo access by adding them to the sudo group:
sudo usermod -aG sudo newuser
Step 3: Setting Up Firewall
Ubuntu 18.04 comes with a built-in firewall called UFW. To enable it, run the following command:
sudo ufw enable
Next, allow SSH connections so you don't get locked out:
sudo ufw allow OpenSSH
You can also allow other services by specifying the port number. For example:
sudo ufw allow 80/tcp
Step 4: Disabling Root Login and Enabling SSH Key Authentication
It is highly recommended to disable root login and enable SSH key authentication for added security. To do so, open the SSH configuration file:
sudo nano /etc/ssh/sshd_config
Find the following lines:
#PermitRootLogin yes
#PasswordAuthentication yes
And change them to:
PermitRootLogin no
PasswordAuthentication no
Next, add your public SSH key to the new user's authorized_keys file:
sudo nano /home/newuser/.ssh/authorized_keys
Paste your public key and save the file.
Step 5: Testing the Configuration
Restart the SSH service for the changes to take effect:
sudo systemctl restart ssh
Finally, test the configuration by logging out and logging back in with your new user:
ssh newuser@your_server_ip
If everything is working correctly, you should be able to log in without a password.
Keywords: Initial Server Setup, Ubuntu 18.04, Tutorial, SSH, Security, Firewall, UFW, Sudo Access, Root Login,
Комментарии
Отправить комментарий