Creating a FTP account for a user

kingfish

Champion of Awesome
Sep 25, 2007
3,497
57
0
I have a site I'm working on where I will need to create an ftp account for a user with limited access just to upload files to a folder on my server.

Searching around I couldn't find a good solution yet. Anyone have any idea how to create the ftp account in php or at least in command line arguments i can run from inside php.

bonus points if you know how to disable reporting of directory structures and other stuff so they can do nothing but upload to their root folder that I define.
 


i'm not sure if this is what you're looking for but can't you create a limited access ftp account via your hosting cpanel/direct admin/ etc. and have it only have access to a certain folder?
 
i'm not sure if this is what you're looking for but can't you create a limited access ftp account via your hosting cpanel/direct admin/ etc. and have it only have access to a certain folder?

Yeah I can do that for now but ultimately I need to automate it for when users sign up so it's done automatically
 
I don't know of a way to do it command line, but you could probably pull it off w/ curl inside cpanel. Never tried it, but I don't see why it wouldn't work.
 
I found someone explaining how to do it on sitepoint via SSH

To create FTP user through SSH you would need to follow below mentioned steps:

1. Login as root through SSH.

2. Next add the user account you want using the 'useradd' command

useradd <username>

3. Now create a special group for that user.

groupadd <groupname>

4. Now to add the user to the group

gpasswd -a <username> <groupname>

These commands are non-standard but available on most popular distributions.
If not, then you can try editing /etc/group using your favorite text editor.

5. Change the group ownership of the special directory to that group.

chgrp -R groupname /path/to/your/web/directory

6. Enable write permissions

chmod -R g+rw /path/to/your/web/directory

Probably varies a bit host to host I would imagine though....