How do I restrict SFTP users access to a specific directory?

Posted on 2009-04-22
Last Modified: 2012-05-06
Hello everybody!

I decided to not use FTP so I don't have to open up port 21, and use SFTP instead.  It works great for me, I use my SSH login.  But I want to set it up for someone else and let them only access the directory with their website, which is "/var/www/website".

So I want to add a new user, that can only access the server via SFTP, and when they log in using an SFTP client, they go straight to that directory and can only go into its subdirectories, not the parent directories.

Question by:parlays
    LVL 7

    Accepted Solution

    LVL 68

    Assisted Solution


    consider using 'rssh'. It supports 'chrooting' and restricting users to any or all of scp, sftp, rsync, rdist or cvs.

    Here it is:

    ... and this is a neat howto:


    LVL 4

    Assisted Solution

    I did exactly this once with SFTP on Redhat 5
    I downloaded openssh 5.1, compiled/installed it then set up my chroot jail in sshd_config
    Here is a guide which has a step by step process:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now