Initial Ubuntu 18.04 Server Setup
Introduction
When you first begin to access your fresh new server, there are a few early steps you should take to make it more secure. Some of the first tasks required on a virtual private server can include setting up a new user, providing them with the proper privileges, and configuring SSH.
- Root login- Once you know your IP address and root password, log in as the main user, root.
ssh root@your_ip
2. Change Your Password
passwd
3. Create a New User
adduser ubuntu
4. Root Privileges- As of yet, the only root has all of the administrative capabilities. We are going to give the new user the root privileges.
visudo
Find the section called user privilege specification. It will look like this:
# User privilege specification
root ALL=(ALL:ALL) ALL
Under there, add the following line, granting all the permissions to your new user:
ubuntu ALL=(ALL:ALL) ALL
Type ‘Cntrl + x’ to exit the file.
Press Y to save; press enter, and the file will save in the proper place.
5. Configure SSH (OPTIONAL)-Now it’s time to make the server more secure. These steps are optional. Please keep in mind that changing the port and restricting root login may make logging in more difficult in the future. If you misplace this information, it could be nearly impossible. Open the configuration file
nano /etc/ssh/sshd_config
Find the following sections and change the information where applicable:
Port 25000
Protocol 2
PermitRootLogin no
Add these lines to the bottom of the document, replacing *demo* in the AllowUsers line with your username. (AllowUsers will limit login to only the users on that line. To avoid this, skip this line):
UseDNS no
AllowUsers ubuntu
6. Reload and Done!- Reload SSH, and it will implement the new ports and settings.
sudo systemctl restart ssh
To test the new settings (don’t log out of root yet), open a new terminal window and log in as your new user. Don’t forget to include the new port number.
ssh -p 25000 ubuntu@your_ip
Your prompt should now say after a successful login:
[ubuntu@hostname ~]$
Where To Go From Here?
At this point, you have a solid foundation for your server. You can install any of the software you need on your server now.
Originally published at https://blog.upendra.tech on September 17, 2017.