Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have SSH access in CentOS server. I have also Plesk 9.2

I want to create a new folder e.g. mytest into my httpdocs and then to add a new FTP user in order to have access only to this folder, I want to see only this directory and not any other.

share|improve this question
    
What FTP server software are you using? VsFTPD or ProFTPD, for example. –  Diziet Mar 23 '12 at 9:48
    
How can I check this? –  paokg4 Mar 27 '12 at 18:40
    
Easies way would be to type: ftp localhost When logged into the server via SSH and see what response it gives. It should tell you via a welcome message. I think it uses VsFTPD but I'm not familiar with it and would like to be sure before I write some instructions. Though any instructions I provide would be command line and assume familiarity with vi or some other editor, e.g. not configuration via plesk. –  Diziet Mar 28 '12 at 9:27
    
I typed ftp localhost but it gives me an error "ftp: command not found". I am using CentOS. –  paokg4 Apr 3 '12 at 15:32
    
If you type ls -l /etc (don't copy and paste the output here) do you see either of: proftpd / vsftpd as directories. If you have one of those that is more than likely the FTP daemon you are running. The other choice is to connect via FTP remotely using whatever software you use and look at the banner. Most windows FTP clients display it in one window or another. –  Diziet Apr 4 '12 at 8:47
show 3 more comments

1 Answer

up vote 1 down vote accepted

Assuming you have root access the procedure can be summarised as follows, where 'pathto' throughout the instructions is the full path ( /something/something/httpdocs/mytest ) and 'myuser' will be the user:

  1. Create new user, with home directory as pathto.
  2. Modify proftpd to jail users.
  3. Modify permissions on mytest.
  4. Restart proftpd.

So first we assume that mytest as a directory already exists and that myuser will be the user and group name. As root we run:

addgroup myuser
adduser --home pathto --no-create-home --group myuser myuser

Then enter a password when prompted.

Now we edit /etc/proftpd/proftpd.conf, you may wish to backup the file first. With your favourite editor ensure that the following is set in the config file:

DefaultRoot ~

this locks logged in users down to their home directories (ymmv, this can have consequences for obvious reasons).

Now we should ensure that the permissions are correct for our new user...

chown myuser:myuser pathto
chmod 755 pathto

755 will give the directory user read/write/execute, user and world read/execute (necessary for apache to see the files therein, give or take).

Now we can restart proftpd and test our changes:

/etc/init.d/proftpd restart

Some things to note about these instructions:

  • You may wish to consider adding /bin/false to /etc/shells and making the users shell /bin/false. This will stop them being able to SSH in but still let them login via FTP. To do that add in --shell /bin/false to the adduser command once you have added the relevant entry to /etc/shells.
  • I've omitted some of the more precise reasoning behind the changes for clarity and simplicity. E.g. permissions.
  • If files exist in pathto already you'll want to fix permissions on those if you want the new user to have control over them.
  • I might have paths and commands such as /etc/init.d/proftpd and /etc/proftpd/proftpd.conf incorrect. I dealt exclusively with debian/ubuntu and thus have almost zero centos/redhat knowledge.

If you need changes to this shout and i'll make them, I just wanted to get something written up, even if slightly wrong.

share|improve this answer
add comment

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.