Given a configuration file, such as sshd_config:
[...]
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
PasswordAuthentication yes
X11Forwarding yes
X11DisplayOffset 10
[...]
I would like to write a command that lets me set a configuration setting. For example, I want to set PasswordAuthentication to no. If the entry already exists, I want to replace it, if it doesn’t, I want to add it at the end of the file.
How can I do that from the shell?
You can use
awkto do this. Here is a script I wrote:Usage: