How to disable root SSH login

To add a user to the wheel group, run the following commands from the root shell:

# adduser myuser     (adds the user)
# passwd myuser    (sets the new user's password)
# usermod -G wheel myuser    (adds the new user to the wheel group)

 

To disable root login through ssh, edit the following file:

# /etc/ssh/sshd_config

browse to the following line:

PermitRootLogin yes

and change to:

PermitRootLogin no

Save the file and restart ssh.

# /etc/init.d/ssh restart   or # service sshd restart


If you are ssh'd into the server with root when this is done, your connection will fail on the restart of ssh so you need to "su" to a different user.

 

If you locked out yourself you can use the VPS Manager console to gain access to your server.

 

  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

Connecting to your VPS via VNC

This knowledge base article will explain how you can connect to your VNC enabled Linux VPS....

How to set reverse DNS (rDNS)

At the moment you need to open a Helpdesk ticket and provide your IP and PTR record you want set,...

My SSH shows "-bash-*". How to change?

When a Xen VPS is delivered and you login for the first time you might see something similar to...

Installing OpenVPN on OpenVZ VPS (CentOS)

You must enable tun/tap and or PPP directly from inside VPS Manager under "settings" tab. then...

How to add website via webmin

This is a great tutorial how you can add new domain/website using webmin....