Role common: add task sftpd.yml for chrooted SFTP access.
- group 'sftpusers' (GID 200 or next free), sshd drop-in /etc/ssh/sshd_config.d/90-sshd-SFTP.conf (Match Group, ChrootDirectory %h, ForceCommand internal-sftp), PasswordAuthentication via 'sftp_password_authentication' - new sftp users (UID 201 or next free) with root owned chroot home, upload dir and root owned authorized_keys (always created) - existing users (e.g. www-data, suexec users) can be added to the group; chroot requirements of their home are checked, not changed - passwords: update_password defaults to 'always', password of users with shell access is never changed - controlled by 'chrooted_sftpd_present' (default: false), tag 'sftpd' - add empty sftpd section to all host_vars *-common.yml Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
#---------------------
|
||||
# Chrooted SFTP Access
|
||||
#---------------------
|
||||
|
||||
Match Group {{ sftp_group_name }}
|
||||
# %h wird durch das Home-Verzeichnis des jeweiligen Users ersetzt
|
||||
# -> automatisch gültig für jeden neuen User dieser Gruppe,
|
||||
# unabhängig vom Wert von USER
|
||||
ChrootDirectory %h
|
||||
|
||||
# Erzwingt IMMER internal-sftp, egal was der Client anfordert.
|
||||
# Überschreibt damit auch die globale "Subsystem sftp"-Zeile
|
||||
# und verhindert jeglichen Shell-Zugriff.
|
||||
ForceCommand internal-sftp
|
||||
|
||||
# Kein Missbrauch der SSH-Verbindung als Tunnel/Proxy möglich
|
||||
AllowTcpForwarding no
|
||||
X11Forwarding no
|
||||
PermitTunnel no
|
||||
|
||||
# Passwort-Login für diese Gruppe explizit gesetzt (unabhängig von
|
||||
# der globalen Einstellung) - Variable 'sftp_password_authentication'
|
||||
PasswordAuthentication {{ sftp_password_authentication }}
|
||||
KbdInteractiveAuthentication no
|
||||
|
||||
# WICHTIG: setzt den Match-Scope zurück auf global,
|
||||
# damit nachfolgende Direktiven (aus dieser Datei, weiteren
|
||||
# sshd_config.d-Dateien oder der Haupt-sshd_config) nicht
|
||||
# ungewollt auch nur für {{ sftp_group_name }} gelten
|
||||
Match all
|
||||
Reference in New Issue
Block a user