I am trying to find and replace a specific string within /etc/ssh/sshd_config.
#PermitRootLogin yes > PermitRootLogin no.
However I want to make sure I get almost any version of it (if that makes sense).
ex;
#PermitRootLogin yes
PermitRootLogin yes
#PermitRootLogin no
I am fairly new to bash, linux, unix etc and have really only been learning this stuff for the past 2 weeks so if possible, please explain to me like i'm brand new to linux/unix. Thank you in advance.
So far i've tried 2 thing so far and neither of them seem to do what I need.
sed -E 's/(#|^)PermitRootLogin(yes|no)/PermitRootLogin no/' FILENAME
and
sed -E 's/(#/|^/)PermitRootlogin(yes/|no/)/PermitRootLogin no/' FILENAME
I was expecting all the lines in the example above to be changed to;
PermitRootLogin no
PermitRootLogin no
PermitRootLogin no