Howto : Add user and Secure your ssh access
One of the biggest security holes you could open on your server is to allow directly logging in as root through ssh. This howto shows you how to add a new user to your server so that you can su or sudo to root from it .
We will begin by how to add a new user to your server,after we will show how to disable root login and use sudo instead.
First Open your terminal, as root type the commands :
root ALL=(ALL) ALL
unixmen ALL=(ALL) ALL
and restart your sshd :
vi /etc/ssh/sshd_config or gedit /etc/ssh/sshd_config
# default value. # default value.
#Port 22 chage with port 31022 (without #)
#Protocol 2,1 #Protocol 2,1
Protocol 2 Protocol 2
#AddressFamily any #AddressFamily any
#ListenAddress 0.0.0.0 #ListenAddress 0.0.0.0
#ListenAddress :: #ListenAddress ::
3- Also we advice you to set the LoginGraceTime, the LoginGraceTime configures the server to disconnect the user after a set amount of time if they have not successfully logged in, to do that , always in your sshd_config file :
4-Now restart SSH. As root run the command:
Now you can run your sshd secure, and will make it hard for others to login to your server.