I want to edit the sshd_config file using bash script. However, I keep getting an error. I would appreciate any help given.
This is my script:
if ! grep "IgnoreRhosts" "/etc/ssh/sshd_config"; then
sed -i /etc/ssh/sshd_config -e '/# Don't read the user's ~/.rhosts and ~/.shosts files/a IgnoreRhosts yes'
printf "\e[32m IGNORERHOSTS YES ADDED\e[0m\n"
elif grep "#IgnoreRhosts yes" "/etc/ssh/sshd_config"; then
sed -i 's/^#IgnoreRhosts yes/IgnoreRhosts yes/' /etc/ssh/sshd_config
printf "\e[32mSUCCESSFULLY CHANGED\e[0m\n"
else
printf "\e[32mNO CHANGES NEEDED\e[0m\n"
fi
This is the error I got:
sed: -e expression #1, char 7: unterminated address regex
Script error line:
sed -i /etc/ssh/sshd_config -e '/# Don't read the user's ~/.rhosts and ~/.shosts files/a IgnoreRhosts yes'