Skip to content

Instantly share code, notes, and snippets.

@tarunbhardwaj
Created February 13, 2016 22:11
Show Gist options
  • Save tarunbhardwaj/3a448301b05621c4edc5 to your computer and use it in GitHub Desktop.
Save tarunbhardwaj/3a448301b05621c4edc5 to your computer and use it in GitHub Desktop.
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>.
    sftp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment