CentOS 7 - Disable Root Login

#!/bin/bash
SEARCH="#PermitRootLogin yes"
REPLACE="PermitRootLogin no"
FILEPATH="/etc/ssh/sshd_config"
sudo sed -i "s;$SEARCH;$REPLACE;" $FILEPATH
sudo service sshd restart

The script is exactly the same for debian users, except the last line in which you need to change sshd to ssh

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites. More info.