[CentOS] change sudoers remotely

Kahlil Hodgson kahlil.hodgson at dealmax.com.au
Mon Jul 8 22:49:23 UTC 2013


You might want to have a look at ansible (www.ansibleworks.com) for
orchestration/configuration tasks like this.  Very simple to set up
and requires nothing but ssh and python on the target host.  Takes
care of all the ssh and sudo user transitions for you.  For your case
it would be as simple as.

    yum install ansible
    echo target_host > hosts
    ansible target_host -i hosts -s -m lineinfile -a
'dest=/etc/sudoers regexp="^username ALL=(ALL) NOPASSWD:"'

replacing target_host and username as appropriate.

You can even package that invocation in a playbook so you don't have
to remember all the details next time.

Hope this helps.

K



More information about the CentOS mailing list