Disable or Enable SSH Root Login and Limit SSH Access in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

15 Responses

  1. Chris Marabate says:

    Nevermind I was getting hacked while I was trying to do this and that was the cause of all my issues. It worked great on the new server I ended up having to install. Sorry about all the comments!

    • Ravi Saive says:

      @Chris,

      Thanks for the latest update, you almost scared me, even I am wondering what’s wrong with my article how its broken your server…..

  2. Chris Marabate says:

    Oh no this is worse than I thought, it appears to have completely broken my server. All my sites are giving me Apache HTTP server error pages. I need help as soon as possible. How could this have broken my server? I can still access the server with Webmin and from the server directly, apache web server is still running.. I don’t understand how just changing the root user permission and changing it back messed everything up so bad.

  3. Chris Marabate says:

    After I disabled root access, I can no longer connect via SSH at all with either Putty or WinSCP. I get the following error before I even get to type in my username… “Network error: Software caused connection abort”

    I even went back and re-enabled root access but it didn’t work, I still can’t access my server using SSH.

    I would appreciate any advice anyone has for me.

    Thanks,

    Chris

  4. Ermir says:

    Hi Ravi,
    I have limitet access for a user to access only his home folder on SFTP(tutorial –> https://www.linode.com/docs/tools-reference/tools/limiting-access-with-sftp-jails-on-debian-and-ubuntu).But now i can’t login via putty with this user.What’s going wrong?
    I put “AllowUsers username” at the botom of sshd_config but still nothing.Please help?

  5. Rajgopal H.G. says:

    Excellent article. Even the first time Linux users can understand and implement it at one shot.!!

  6. Ilya says:

    There are steps in the article like this:

    Restart the sshd service.
    # /etc/init.d/sshd restart

    Restarting can kill existing SSH connections to the host.

    Instead of restarting when only reconfiguration is needed you can send SSHD process the SIGHUP signal with KILL command:

    sudo kill -s SIGHUP $SSHDPID

    You will need $SSHDPID, process ID for SSHD , it can be found by a command like

    ps -AF | grep /usr/sbin/sshd

  7. Garik says:

    Hello!
    Thank you for yours very usefull articles. You are a master!

  8. k satyanarayana says:

    Need document of ” how to existing windows 2003 domain convert into Linux domain without distrubence of existing.

  9. Matt says:

    Hi Ravi,

    I have disabled the root SSH on CentOS with Cpanel.
    I need to reenable it but my other user now can’t access the # vi /etc/ssh/sshd_config

    User apparently does not have the sudo rights I guess..
    What can I do?

    Thank you

    • Ravi Saive says:

      Why you allowing your normal user to access sshd_config file?

    • Vien Mai says:

      You can open ssh session to the server with normal user then issue sudo su (On Ubuntu) to change to root then you can re-enable ssh for root. However, I have heard that login by root account over SSH is not encouraged due to security reason.

  10. rahul says:

    hello. thank you for this.
    i like your article.
    you are very perfect in it.
    good luck

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 150K+ Linux Users
  1. 100,756
  2. 5,113
  3. 36,418

Enter your email to get latest Linux Howto's