CentOS 7 Initial Setup Introduction
Every server needs to be secured, so there are a few basic steps you should take as soon as you spin up a new VPS. This guide will help you secure your with some general tips for CentOS 7 initial setup.
Step One – Root Login
You’ll need the following to login to your VPS.
- Public IP Address
- The “root” password
These can be found in your Welcome Email sent to you when you set up your VPS.
If you aren’t already connected, use the following in your CLI client to connect, replacing the text in red with your the pubic IP for your VPS.
ssh [email protected]SERVER_IP_ADDRESS
You may receive a warning about the host authenticity is unable to be verified, simply follow the prompt to continue connecting and type in your root password to finish logging into your VPS.
The root user is the equivalent of the Windows administrator account. Because of the additional access this account has to the system, it is not recommended to use this as your primary account for connecting or performing tasks on the VPS. It is extremely easy to cause issues with your OS by entering the wrong command or changing something as the root user.
Below we’ll show you how to setup a user you can use and grant root priveleges as needed rather than using root at all times.
Step Two – Create a New User
While logged in as the root user, run the following command to create a new user. Make sure to replace the text in red with the name of the user you want to use.
Next, you need to give the user you created a password. Run the following command, again making sure to replace the text in red with the name of the user you just created. Then follow the prompts to finish setting up the new user account.
Step Three – Granting Root Access To Your New User
The new user currently has no root access. Here is where we’ll give it root access, so that if needed you can run things with the priveledge of the root account. Since this is CentOS 7, what we are going to do is add the new user to the “wheel” group. Every version of linux has a group like this, and “wheel” is the group for CentOS 7.
Any account that is part of the “wheel” group of users is able to run commands as root without the need to sign into the root account simply by starting a command with “sudo”. Think of it like giving Administrator access to an account in Windows.
Adding the User to “wheel”
While logged in as root, run the command below to add the user you created to the “wheel” group. As always, make sure you change the red text to the name of the user you created.
gpasswd -a username wheel
And that should be it! Your intial setup is complete! From here we recommend also configuring your firewall of choice as well as setting up SSH key authentication. Guides on how to do this are coming soon if you need them, so check back shortly for those!