# How to append the new group to the existing AllowGroups line in /etc/ssh/sshd\_config

**URL:** <https://forum.ansible.com/t/how-to-append-the-new-group-to-the-existing-allowgroups-line-in-etc-ssh-sshd-config/35934>\
**Category:** Ansible Developer\
**Created:** [October 28, 2021, 12:24pm UTC](https://forum.ansible.com/t/how-to-append-the-new-group-to-the-existing-allowgroups-line-in-etc-ssh-sshd-config/35934 "2021-10-28T12:24:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suresh\_Karpurapu](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Suresh\_Karpurapu](https://forum.ansible.com/u/Suresh_Karpurapu)\
**Post date:** [October 28, 2021, 12:24pm UTC](https://forum.ansible.com/t/how-to-append-the-new-group-to-the-existing-allowgroups-line-in-etc-ssh-sshd-config/35934/1 "2021-10-28T12:24:19Z")

</div>

HI Experts,

I would like to append the new group to the existing AllowGroups in /etc/ssh/sshd\_config file without disturbing the existing group. I tried with lineinfile module but unfortunately its failing or overwriting existing groups. Can anyone please provide the clue on logic?

existing setup:

# grep AllowGroups /etc/ssh/sshd\_config

AllowGroups x y z

required setup: let’s assume “a” is new group, then i am looking as below

# grep AllowGroups /etc/ssh/sshd\_config

AllowGroups x y z a \<-----group “a” needs to be added at the end of the line

Once again thanks for your help

Regards,  
Suresh
