This and sed
Sed is a nice little tool that is quite hard to understand. While a longer tutorial can be found here. I found it especially useful for editing config files.
If you want to deny root login via ssh you can simply enter this command:
It uses pattern matching a la perl and s/ searches for a line that ^starts with "PermitRootLogin" followed by one or more other characters. After the second slash we enter how it is replaced and here \1 fills in the bracketed "PermitRootLogin" string and then we add "no".
In Perl this would look like this:
If you want to deny root login via ssh you can simply enter this command:
# sudo sed -ir 's/^(PermitRootLogin) .+/\1 no/' /etc/ssh/sshd_config
It uses pattern matching a la perl and s/ searches for a line that ^starts with "PermitRootLogin" followed by one or more other characters. After the second slash we enter how it is replaced and here \1 fills in the bracketed "PermitRootLogin" string and then we add "no".
In Perl this would look like this:
# sudo perl -pi -e 's/^PermitRootLogin.+/PermitRootLogin no/' /etc/ssh/sshd_config
Kommentare
Kommentar veröffentlichen