1

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.

7
  • What FTP server software are you using? VsFTPD or ProFTPD, for example.
    – Diziet
    Mar 23, 2012 at 9:48
  • How can I check this?
    – AlexCode
    Mar 27, 2012 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, 2012 at 9:27
  • I typed ftp localhost but it gives me an error "ftp: command not found". I am using CentOS.
    – AlexCode
    Apr 3, 2012 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, 2012 at 8:47

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .