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?
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.
sed
,awk
andperl
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.