I have this settings in SSH configs (/etc/ssh/sshd_config
)
AllowUsers root john
I want to add jane
to the end of the line
AllowUsers root john jane
I've tried
sed -i -e '/AllowUsers/{s/:/ /g;s/.*=//;s/$/ jane/p}' /etc/ssh/sshd_config && cat /etc/ssh/sshd_config
I kept getting this result
AllowUsers root john jane
AllowUsers root john jane
Why does extra line come?
Note
If I somehow run that command twice
I will get these result
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
run it again x3 times, will get me this
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane
AllowUsers root john jane