When you first begin to approach your newly installed server, there are a few early steps you should take to make it more secure from hackers. The first tasks can include setting up a new user, providing them with the proper privileges, and configuring SSH.
Step One — Login via Root
Step Two — Change Your Password For Root
CentOS is very cautious about the passwords it allows. After you type your password, you may see a BAD PASSWORD notice. You can either set a more complex password or ignore the message .
Step Three — Creating a New User For Root privileges
First, create your user; you can choose any name for your user.
For example here I’ve suggested secure as a user .
Second, create a new user password :
Step Four — Assigning Root Privileges
As of yet, only root has all of the administrative capabilities. We are going to give the new user the root privileges.
Let’s go ahead and edit the sudo configuration. This can be done through the default editor, which in CentOS is called ‘vi’
Find the section called user privilege specification and add the similar line below it .
To began typing in vi, press “a”.
Then to save and exit press escape , then press ":w" to write the file and to quit press ":q" .
Step Five — Configuring SSH To Disable Root Login
Open the configuration file
It will then look something like this :
Find the following sections and change the information where applicable:
Port 750 ( <-- you can change it to any port , it will disable 22 as default port for accessing ssh)
Protocol 2
PermitRootLogin no ( <-- This will disable direct root login )
It will then look something like this :-
Once the above is done , just add the below line to the bottom of the document, replacing secure with your username:
Save and Exit
Step Six — Reload and Done!
Reload SSH, and it will implement the new ports and settings.
Finally you can login to your SSH using the user secure with port 750 .
Few more steps that can be done to get the thing more secured :- http://www.wjunction.com/1820961-post5.htm
I hope this will help and few users to secure the SSH from unauthorized people .
Step One — Login via Root
Step Two — Change Your Password For Root
CentOS is very cautious about the passwords it allows. After you type your password, you may see a BAD PASSWORD notice. You can either set a more complex password or ignore the message .
Step Three — Creating a New User For Root privileges
First, create your user; you can choose any name for your user.
Code:
adduser username
For example here I’ve suggested secure as a user .
Second, create a new user password :
Code:
passwd secure
Step Four — Assigning Root Privileges
As of yet, only root has all of the administrative capabilities. We are going to give the new user the root privileges.
Let’s go ahead and edit the sudo configuration. This can be done through the default editor, which in CentOS is called ‘vi’
Code:
/usr/sbin/visudo
Find the section called user privilege specification and add the similar line below it .
To began typing in vi, press “a”.
Code:
secure ALL=(ALL) ALL
Then to save and exit press escape , then press ":w" to write the file and to quit press ":q" .
Step Five — Configuring SSH To Disable Root Login
Open the configuration file
Code:
sudo vi /etc/ssh/sshd_config
It will then look something like this :
Find the following sections and change the information where applicable:
Port 750 ( <-- you can change it to any port , it will disable 22 as default port for accessing ssh)
Protocol 2
PermitRootLogin no ( <-- This will disable direct root login )
It will then look something like this :-
Once the above is done , just add the below line to the bottom of the document, replacing secure with your username:
Code:
AllowUsers secure
Save and Exit
Step Six — Reload and Done!
Reload SSH, and it will implement the new ports and settings.
Code:
service sshd restart
Finally you can login to your SSH using the user secure with port 750 .
Few more steps that can be done to get the thing more secured :- http://www.wjunction.com/1820961-post5.htm
I hope this will help and few users to secure the SSH from unauthorized people .
Last edited: