Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable SSH login for SFTP users #11

Merged
merged 2 commits into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ The following role variables are relevant:
* `sftp_users`: A list of users, in map form, containing the following elements:
* `name`: The Unix name of the user that requires SFTP access.
* `password`: A password hash for the user to login with. Blank passwords can be set with `password: ""`. NOTE: It appears that `UsePAM yes` and `PermitEmptyPassword yes` need to be set in `sshd_config` in order for blank passwords to work properly. Making those changes currently falls outside the scope of this role and will need to be done externally.
* `authorized`: A list of files placed in `files/` which contain valid public keys for the SFTP user.
* `shell`: Boolean indicating if the user should have a shell access (default to `True`).
* `authorized`: An optional list of files placed in `files/` which contain valid public keys for the SFTP user.


## Example Playbook
Expand All @@ -44,7 +45,7 @@ The following role variables are relevant:
- sftp_users:
- name: peter
password: "$1$salty$li5TXAa2G6oxHTDkqx3Dz/" # passpass
authorized: []
shell: False
- name: sally
password: ""
authorized: [sally.pub]
Expand Down
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
name: "{{ item.name }}"
groups: "{{ sftp_group_name }}"
home: "{{ sftp_home_partition }}/{{ item.name }}"
# `None` means default value -> default is to have a shell
shell: "{{ None if (item.shell | default(True)) else '/sbin/nologin' }}"
state: present
with_items: "{{ sftp_users }}"

Expand All @@ -70,6 +72,8 @@
with_subelements:
- "{{ sftp_users }}"
- authorized
- flags:
skip_missing: True

# Update user passwords, if they were specified.
- name: SFTP-Server | Update user passwords
Expand Down