The first thing to do, when you setup a new server is to disable root access via ssh
First you need to login with root privileges and create a new user and assign to it a new password
adduser pippo
passwrd pippo
then locate and edit you sshd_config file (usually under/etc/ssh/sshd_config)
vi /etc/ssh/sshd_config
# Change the default port
# Locate the line Port and change it to a custom one (ex. 22222)
Port 22222
# Locate the line PermitRootLogin and change it to
PermitRootLogin no
After that restart the sshd service (in case of centos this is the command)
service sshd restart
Then try a login with a new shell (in case of problem you can fix it 🙂 )
[user@localhost] ssh -p 22222 pippo@remotehost
insert password
[pippo@remotehost] exit
# then try with root
[user@localhost] ssh -p 22222 <rootuser>@remotehost
insert password
# an error is expected
# then try default port
[user@localhost] ssh pippo@remotehost
# an error is expected
More info on https://mediatemple.net/community/products/dv/204643810/how-do-i-disable-ssh-login-for-the-root-user
0 Comments