Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Sorry if this is an obvious question, but I don't have a lot of knowledge about this sort of thing, and I've googled for hours, nothing worked.

So on a Ubuntu 11.04 server, I want to restrict a user to a specific directory (so he can't access the parents' directory) for FTP/ssh. I created the user with adduser username and changed the target directory with usermod -d /home/path/to/directory username. This worked perfectly.

From what I found I have to modify a /etc/ftp/ftpaccess file but the file (and the ftp) directory does not exist. I tried creating it but it didn't change anything. Also I only want to restrict this user and not the others.

Any ideas?

share|improve this question

2 Answers 2

The best way, is to use SFTP from SSH and jail the user.

in file: /etc/ssh/sshd_config

make sure this line is uncomented:

Subsystem sftp internal-sftp

Then configure the rule to match a group:

Match group sftponly
         ChrootDirectory /home/%u
         X11Forwarding no
         AllowTcpForwarding no
         ForceCommand internal-sftp

and lastly manage the users:

# chown root.root /home/user
# usermod -d / user
# adduser user sftponly

Source: http://www.debian-administration.org/articles/590

share|improve this answer
    
For not affecting the usage of sftp for users that belong to a group other than "sftponly" (i.e. keeping), could I specify the Subsystem command inside the match, leaving the previous configuration unchanged? –  niconic Nov 17 at 12:01

You need to install a FTP Server first! Read the documentation:

You need to chose one of the FTP Servers in the comment .. Or if you have already installed SSH you can use SFTP.. To do this, just on your FTP client type:

  • Host: sftp://ssh_server_hostname_or_ip
  • login:your_ssh_server_user_name
  • pass: your_ssh_server_user_password

You'll be able to r/w on all the directories that belong to your ssh user

share|improve this answer
    
    
The ssh / sftp login works, I just want to restrict the user to a directory –  romainberger Aug 1 '13 at 10:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.