# Creating a new user with SSH rights on OS X

**URL:** <https://forum.ansible.com/t/creating-a-new-user-with-ssh-rights-on-os-x/19048>\
**Category:** Ansible Project\
**Created:** [August 19, 2015, 7:32am UTC](https://forum.ansible.com/t/creating-a-new-user-with-ssh-rights-on-os-x/19048 "2015-08-19T07:32:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Green](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Anthony\_Green](https://forum.ansible.com/u/Anthony_Green)\
**Post date:** [August 19, 2015, 7:32am UTC](https://forum.ansible.com/t/creating-a-new-user-with-ssh-rights-on-os-x/19048/1 "2015-08-19T07:32:37Z")

</div>

I’ve been trying to use the group and user module to create a user account that has SSH rights.

the tasks i’m running are:

- name: Add jenkins user  
user: name=jenkins comment=Jenkins password=foobar system=yes  
sudo: yes

and although the user is created SSH isn’t set up properly: If I try to connect as the user jenkins I get authenticated but the connection immediately closes.

previously I’d used a sequence of shell commands:

- name: Create Jenkins user  
shell: “{{item}}”  
with\_items:
- “dscl . -create /Users/jenkins”
- “dscl . -create /Users/jenkins UserShell /bin/bash”
- “dscl . -create /Users/jenkins RealName ‘Jenkins’”
- “dscl . -create /Users/jenkins UniqueID {{unique\_id\_generator.stdout}}”
- “dscl . -create /Users/jenkins PrimaryGroupID 20”
- “dscl . -create /Users/jenkins NFSHomeDirectory /Users/jenkins”
- “createhomedir -c \> /dev/null”
- “dscl . append /Groups/com.apple.access\_ssh user jenkins”
- “dscl . append /Groups/com.apple.access\_ssh groupmembers `dscl . read /Users/jenkins GeneratedUID | cut -d ' ' -f 2`”
- “dscl . -passwd /Users/jenkins foobar”  
sudo: yes

and this does work

Any ideas or is this a bug in the user module?

---

<div class="post-metadata">

**Author:** ![Anthony\_Green](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Anthony\_Green](https://forum.ansible.com/u/Anthony_Green)\
**Post date:** [August 19, 2015, 9:55am UTC](https://forum.ansible.com/t/creating-a-new-user-with-ssh-rights-on-os-x/19048/2 "2015-08-19T09:55:03Z")

</div>

the answer was to add the user to the ssh group and set the shell

- name: Add jenkins user  
user: name=jenkins comment=Jenkins password=foobar groups=com.apple.access\_ssh shell=/bin/bash  
sudo: yes
