File tree 3 files changed +23
-2
lines changed
3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ sftp_group_name: sftpusers
4
4
sftp_directories : []
5
5
sftp_allow_passwords : False
6
6
sftp_enable_selinux_support : False
7
+ sftp_enable_logging : False
Original file line number Diff line number Diff line change 4
4
name : " {{ 'ssh' if ansible_os_family == 'Debian' else 'sshd' }}"
5
5
state : restarted
6
6
ignore_errors : Yes
7
+
8
+ - name : SFTP-Server | Restart rsyslog
9
+ service :
10
+ name : rsyslog
11
+ state : restarted
Original file line number Diff line number Diff line change 39
39
ChrootDirectory %h
40
40
AllowTCPForwarding no
41
41
X11Forwarding no
42
- ForceCommand internal-sftp
43
- PasswordAuthentication {% if sftp_allow_passwords %} yes{% else %}no{% endif % }
42
+ ForceCommand internal-sftp {{ sftp_enable_logging | ternary('-l VERBOSE', '') }}
43
+ PasswordAuthentication {{ sftp_allow_passwords | ternary(' yes', 'no') } }
44
44
notify : SFTP-Server | Restart sshd
45
45
46
46
# Create each SFTP user with home directory on the correct partition, and add to SFTP group.
93
93
with_nested :
94
94
- " {{ sftp_users }}"
95
95
- " {{ sftp_directories }}"
96
+
97
+ - name : SFTP-Server | Enable Logging
98
+ blockinfile :
99
+ dest : " /etc/rsyslog.d/{{ item.name }}.conf"
100
+ create : yes
101
+ block : |
102
+ # Create an additional socket for some of the sshd chrooted users.
103
+ $AddUnixListenSocket /home/{{ item.name }}/dev/log
104
+
105
+ # Log internal-sftp in a separate file
106
+ :programname, isequal, "internal-sftp" -/var/log/sftp_{{ item.name }}.log
107
+ :programname, isequal, "internal-sftp" ~
108
+ with_items : " {{ sftp_users }}"
109
+ when : sftp_enable_logging
110
+ notify : SFTP-Server | Restart rsyslog
You can’t perform that action at this time.
0 commit comments