For example, I often need to login to a new virtual machine just to open "/etc/ssh/sshd_config" and set "PasswordAuthentication" option to "no".

In this way, I can not automate this process.

How to solve similar tasks by doing the modification from the command line?

link|improve this question
feedback

3 Answers

up vote 1 down vote accepted
# sed -i -r 's/^#?PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config
link|improve this answer
feedback

If you want to go whole hog into centralized configuration management, you can look at tools like Puppet and Chef. One can argue that this way lies both madness and salvation.

Depending on what you're trying to do and how many machines you're handling, investing in running a Puppet or Chef server may be like hammering a nail by dropping an aircraft carrier on it. On the other hand, an aircraft carrier may be what you actually need, depending on what you're trying to do.

link|improve this answer
feedback

sed, awk and perl are your friends. If not, you should have a look at them. As configuration files are different from software to software there cannot be a general solution. Create your own solution.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.