http://linuxtechlab.com/ultimate-guide-to-securing-ssh-sessions
Hi Linux-fanatics, in this tutorial we will be discussing some ways with which we make our ssh server more secure. OpenSSH is currently used by default to work on servers as physical access to servers is very limited. We use ssh to copy/backup files/folders, to remotely execute commands etc. But these ssh connections might not be as secure as we believee & we must make some changes to our default settings to make them more secure.
Here are steps needed to secure our ssh sessions,
It should have at-least 8 characters with numbers & alphabets, lower case & upper case letter, and also special characters. A good example would be “vXdrf23#$wd” , it is not a word so dictionary attack will be useless & has uppercase, lowercase characters, numbers & special characters.
& add the allowed users to the bottom of the file
Save the file & restart the service. Now only Bob & Susan will have access to ssh , others won’t be able to access ssh.
So, its wise to reduce idle log-out time to something around 5 minutes & it can be done in config file only. Open ‘/etc/ssh/sshd_config’ & change the values
Its in seconds, so configure them accordingly.
To disable root access, open your configuration file & change the following parameter
This will disable root access to ssh sessions.
After this file is create, open sshd_config file & enter the following parameter into the file
now you warning message will be displayed each time someone tries to access the session.
To change port, open sshd_config & change the following parameter
Save
& restart the service and you can access the ssh only with this new
port. To start a session with custom port use the following command
Note:-
If using firewall, open the port on your firewall & we must also
change the SELinux settings if using a custom port for ssh. Run the
following command to update the SELinux label
Now ssh session will only be available to these mentioned IPs with the custom port 15000.
So, this completes our tutorial on securing your ssh server. If having any doubts or issues, please leave a message in the comment box below.
Hi Linux-fanatics, in this tutorial we will be discussing some ways with which we make our ssh server more secure. OpenSSH is currently used by default to work on servers as physical access to servers is very limited. We use ssh to copy/backup files/folders, to remotely execute commands etc. But these ssh connections might not be as secure as we believee & we must make some changes to our default settings to make them more secure.
Use complex username & password
It should have at-least 8 characters with numbers & alphabets, lower case & upper case letter, and also special characters. A good example would be “vXdrf23#$wd” , it is not a word so dictionary attack will be useless & has uppercase, lowercase characters, numbers & special characters.
Limit user logins
$ vi /etc/ssh/sshd_config
AllowUsers bob susan
Configure Idle logout time
So, its wise to reduce idle log-out time to something around 5 minutes & it can be done in config file only. Open ‘/etc/ssh/sshd_config’ & change the values
ClientAliveInterval 300
ClientAliveCountMax 0
ClientAliveCountMax 0
Disable root logins
To disable root access, open your configuration file & change the following parameter
PermitRootLogin no
ClientAliveCountMax 0
ClientAliveCountMax 0
Enable Protocol 2
Protocol 2
Enable a warning screen
After this file is create, open sshd_config file & enter the following parameter into the file
Banner /etc/issue
Use non-standard ssh port
To change port, open sshd_config & change the following parameter
Port 15000
$ ssh –p 15000 {server IP}
$ semanage port -a -t ssh_port_t -p tcp 15000
Limit IP access
Port 15000
ListenAddress 192.168.1.100
ListenAddress 192.168.1.115
ListenAddress 192.168.1.100
ListenAddress 192.168.1.115
Disable empty passwords
PermitEmptyPasswords no
Use public/private key based authentication
So, this completes our tutorial on securing your ssh server. If having any doubts or issues, please leave a message in the comment box below.
No comments:
Post a Comment