tech:monter_un_serveur_sftp_chroote_avec_openssh
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:monter_un_serveur_sftp_chroote_avec_openssh [2025/09/18 15:14] – Jean-Baptiste | tech:monter_un_serveur_sftp_chroote_avec_openssh [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Monter un serveur SFTP chroote avec OpenSSH | ||
| + | |||
| + | Voir : https:// | ||
| + | |||
| + | Voir aussi : | ||
| + | * [[draft-monter-un-serveur-sftp-ssh|Monter un serveur SFTP avec ProFTPd]] | ||
| + | * [[SSH SFTP chroot]] | ||
| + | |||
| + | ~~~bash | ||
| + | mkdir -p / | ||
| + | chown root:nsc /chroot | ||
| + | chmod 750 /chroot | ||
| + | |||
| + | useradd sftpuser -M -d /dev/null -s / | ||
| + | # useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead. | ||
| + | |||
| + | echo "/ | ||
| + | ~~~ | ||
| + | |||
| + | `/ | ||
| + | ~~~ | ||
| + | # Subsystem sftp / | ||
| + | Subsystem | ||
| + | |||
| + | Match User sftpuser | ||
| + | ChrootDirectory /chroot | ||
| + | ForceCommand internal-sftp | ||
| + | AllowTcpForwarding no | ||
| + | GatewayPorts no | ||
| + | X11Forwarding no | ||
| + | PermitTunnel no | ||
| + | AllowAgentForwarding no | ||
| + | PermitTTY no | ||
| + | |||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | mount / | ||
| + | systemctl restart sshd | ||
| + | systemctl status sshd | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | The simplest way is to create some script that would take care of that. Add | ||
| + | |||
| + | ~~~ | ||
| + | Match User test1 | ||
| + | ForceCommand / | ||
| + | ~~~ | ||
| + | And your script will basically run whatever the user wants, unless it is request for SFTP: | ||
| + | |||
| + | ~~~bash | ||
| + | #!/bin/bash | ||
| + | if [[ " | ||
| + | echo "SFTP not allowed" | ||
| + | exit 255; | ||
| + | else | ||
| + | exec " | ||
| + | fi | ||
| + | ~~~ | ||
| + | |||
| + | FIXME | ||
| + | |||
