Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, bool given in /data/wwwroot/www.bgknews.com/wp-includes/wp-db.php on line 3380

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, bool given in /data/wwwroot/www.bgknews.com/wp-includes/wp-db.php on line 3380
Secure Linux VPS Quickly by disabling root - BGKNews - Web Development & Technology News, tips-tricks & Hows-To's.
selective focus photography of yellow padlock
cyber-seucurity

Secure Linux VPS Quickly by disabling root

How to Secure Linux VPS
How to Secure Linux VPS

Linux VPS/Dedicated Server Security

Linux offers many distro’s and by default the root account gets enabled during setup. This adds a serious issue for security and in CentOS we can fix this by adding an administrative account and disabling the “root”. So by doing so we can run any task with root permissions by running the command with sudo .

Disable root on CentOS VPS

The ArchLinux team provided a detailed documentation about this guide, but i am elaborating it for quick and easy to use commands that will get you started quickly. (Visit here for ArchLinux Documentation)

  1. Login to your CentOS VPS and switch to your root account by running su and then enter your root account password.
  2. Enabling sudo. If you don’t like vim then you can always use gedit or “nano” , its upto you.
export EDITOR=gedit

After this, enter

/usr/sbin/visudo

The lines starting with # are comment lines and will be ignored. Just uncomment the following line:

# %wheel  ALL=(ALL)       ALL

by removing the # at the beginning. This line means that anybody in the group wheel can use sudo to run anything from anywhere.

  1. Add an account to group wheel. For example, if the account you use to perform administrative task is johndoe, run
gpasswd -a johndoe wheel

Now you can sudo from user johndoe

  1. Disable root account. You can always disable the root account by running:
passwd -l root

These are the most basic and early steps whenever you buy a new VPS, so good luck with this! I will be posting more guides relating to this soon.