www.digitaldaze.com
Can I change the FTP home directory?

" Can I change the FTP home directory? I would like to setup a structure where three users have an FTP directory in my htdocs directory... but I would like one other user to have access to each of those three users ftp directories. Is this possible? "

Yes this is possible!

When you set up an FTP/Mail account for each user, by default it gives you 3 options for the directories. Option 2 allows the users home directory to be placed in the "usr/local/etc/httpd/htdocs" directory structure so that not only will the directory be accessible via FTP but also via the web as well.

I set up three accounts on a virtual server: test1, test2, and test3 and gave each an FTP directory in the "usr/local/etc/httpd/htdocs" directory structure using Option 2. If I look at the "etc/passwd" file I see something like this:

test1:WC6LNEOeRdHHQ:148:100:test1:/usr/local/etc/httpd/htdocs/test1:ftp
test2:SG.TMTcirDKac:148:100:test2:/usr/local/etc/httpd/htdocs/test2:ftp
test3:jHDYINousVz2c:148:100:test3:/usr/local/etc/httpd/htdocs/test3:ftp

Notice the ftp directory listing is included in the definition of each user. And in fact, there are directories "test1", "test2", and "test3" in the "htdocs" directory. Now let's say that "mike" is going to be in charge of the "test1", "test2", and "test3" accounts. We would like to set it up such that we give "mike" an ftp account/password that will allow him to have access to each of the accounts. Here's how:

Use "vadduser" to add an FTP/Mail account with FTP option 2. There will now be a "mike" directory in the "usr/local/etc/httpd/htdocs" directory structure and in the "etc/passwd" file Mike will now have an entry:

test1:WC6LNEOeRdHHQ:148:100:test1:/usr/local/etc/httpd/htdocs/test1:ftp
test2:SG.TMTcirDKac:148:100:test2:/usr/local/etc/httpd/htdocs/test2:ftp
test3:jHDYINousVz2c:148:100:test3:/usr/local/etc/httpd/htdocs/test3:ftp
mike:xLABZ9LPRmSJM:148:100:mike:/usr/local/etc/httpd/htdocs/mike:ftp

To give Mike access to the "test1", "test2", and "test3" accounts, we will need to put the accounts in Mike's directory. So we will want to do two things:

  1. Change the directory specification in the "etc/passwd" file.
  2. Physically move the "test1", "test2", and "test3" account directories into the "mike" directory.

Change the directory specification in the "etc/passwd" file.

test1:WC6LNEOeRdHHQ:148:100:test1:/usr/local/etc/httpd/htdocs/mike/test1:ftp
test2:SG.TMTcirDKac:148:100:test2:/usr/local/etc/httpd/htdocs/mike/test2:ftp
test3:jHDYINousVz2c:148:100:test3:/usr/local/etc/httpd/htdocs/mike/test3:ftp
mike:xLABZ9LPRmSJM:148:100:mike:/usr/local/etc/httpd/htdocs/mike:ftp

Notice how I added the "mike" directory in the directory specification for "test1", "test2", and "test3".

Physically move the "test1", "test2", and "test3" account directories into the "mike" directory.

You can do this my using the "mv" command. In this example, I can do this my typing the following commands:

cd               (puts me in my home directory)
cd www/htdocs    (puts me in the htdocs directory)
mv test1 mike    (move the test1 directory into the mike directory)
mv test2 mike    (move the test2 directory into the mike directory)
mv test3 mike    (move the test3 directory into the mike directory)

We're done! Notice what both test1 and Mike see when they ftp to the virtual server:

*** Here is what test1 will see ***

% ftp ftp.digitaldaze.com
Connected to www.digitaldaze.com.
220 ftp.digitaldaze.com ftp server (Version 4.1) ready.
Name (ftp.digitaldaze.com): test1
331 Password required for test1.
Password:
230 User test1 logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/" is current directory.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 2
-rw-rw-r--    1 148      100             7 Jan 24 10:27 test1.html
226 Transfer complete.
ftp> quit
221 Goodbye.

*** Here is what mike will see ***

% ftp ftp.digitaldaze.com
Connected to www.digitaldaze.com.
220 ftp.digitaldaze.com ftp server (Version 4.1) ready.
Name (ftp.digitaldaze.com): mike
331 Password required for mike.
Password:
230 User mike logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/" is current directory.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 6
drwxr-xr-x    2 148      100           512 Jan 24 10:27 test1
drwxr-xr-x    2 148      100           512 Jan 24 10:26 test2
drwxr-xr-x    2 148      100           512 Jan 24 10:26 test3
226 Transfer complete.
ftp> cd test1
250 CWD command successful.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 2
-rw-rw-r--    1 148      100             7 Jan 24 10:27 test1.html
226 Transfer complete.
ftp> quit
221 Goodbye.
 

[Legal Notice]
http://www.digitaldaze.com