This question already has an answer here:
- How can I replace a string in a file(s)? 7 answers
I am writing a script to modify settings on my Ubuntu server.
I have the following line in it:
sudo sed 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
The problem is that the change will not remain. It simply changes the 'no' back to 'yes'.
When the command executes, the modified file immediately displays in the terminal showing the 'no', but when I cat the file or open it in vim it shows a 'yes' again.
Additionaly, I can open sshd_config in vim and modify it manually and the change remains just fine.