Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

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

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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