Faye Faye - 10 days ago 6
Linux Question

root login must be su instead of loginning directly in Redhat , how to set?

In RedHat , I want to login with other user firstly in SSH, such as the user input when installing OS , then su - root , instead of being able to login with root directly in SSH
How to set in command line and config files ? I have no UI .

Answer

If you want to stop remote login through ssh by root. You just edit configuration file of ssh server.

  # vim /etc/ssh/sshd_config
    #PermitRootLogin yes

remove # and replace yes to no

     PermitRootLogin no

after that restart sshd deamon.if you are in centos6/5/RHEL6/5/ubuntu

   # /etc/init.d/sshd restart

or If your are in centos7/RHEL7/Ubuntu

   # systemctl restart sshd.service