Jump to content
MazaBoY

Increase Linux server security by 50% in 5 minutes.

Recommended Posts

In this small tutorial I'm showing the webmasters how to increase your server security by 50% in just 5 minutes.

How is this possible?

Most servers are getting hacked by unsecured SSH services, most of the time servers get brute forced to gain root access. Brute forcing is a hacking method by guessing the server root password, done by a script.

How are we preventing this?

We are going to disable root login, we are going to create a new user account. By disabling the root account, the brute forcer can't proceed because the username is unknown!

How do I connect after applying this tutorial?

Simply connect using the new username and password, after logged in you only have to execute 'su root' to switch to root. It will ask for the root password, once entered you are root in your server.

Part 1 - Creating a new user.

1. Login into your server by SSH, using PuTTY.

2. Execute the following commands:

useradd USERNAMEHERE

passwd USERNAMEHERE

USERNAMEHERE = Your desired login name for SSH.

After executing the passwd command the console will ask you for a password. Be sure you use a secure password. (one capital, small letters, special chars and numbers. Example: RSTcenter881^359$)

Now we have your new account.

Part 2 - Changing the SSH settings.

3. Be sure you have nano install, if not execute the following:

yum install -y nano

4.Now execute this:

nano /etc/ssh/sshd_config

Scroll down and find '#Port 22' and uncomment it. Change 22 to your desired SSH port. Pick a port number between 49152 and 65535, this is recommended.

Then find the line '#PermitRootLogin yes' and uncomment it. Change yes to no.

Close nano by Ctrl + X, then type Y and hit enter.

Part 3 - Adjusting Firewall rules.

5. We need to open the port in iptables, this is done through these commands:

iptables -t filter -A OUTPUT -p tcp --dport PORTNUMBERHERE -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport PORTNUMBERHERE -j ACCEPT
service iptables save
service iptables restart

PORTNUMBERHERE = Your port number used in the SSH config.

6. Reload SSH config by executing:

service sshd reload

IMPORTANT: Before you close the current Putty console, please open up a new console and try to connect using the new settings. If it works then you can close the "old" console, but it you fail to login you can always revert the settings.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...