Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setup sftp with chroot

Setup SFTP with chroot

  1. Create folder to chroot mkdir /opt/sftp

  2. Change ownership chown root:root /opt/sftp

  3. Change mode chmod go-w /opt/sftp

  4. Change sshd config /etc/ssh/sshd_config

    Subsystem sftp  internal-sftp
    Match User <sftp user>
        ChrootDirectory /opt/sftp
        X11Forwarding no
        AllowTcpForwarding no
        ForceCommand internal-sftp
  5. Restart sshd service sshd restart

  6. Login sftp <sftp-user>@<host>

    Connected to <host>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment