Redirect user to dir upon SFTP connection

0

I have an FTP user which i log in into the server via SFTP and a key file. Right, lovely, works like a charm.

Now, by default the user logs to /home/ftp which is not cool. I'd like to know if there is a way to redirect just before the connection to a dir such as /var/www/site.com/public/files/

Mmm? :)

Gabriel A. Zorrilla

Posted 2009-09-02T19:13:27.543

Reputation: 3 245

Answers

0

You will need to make changes on the server. Since you didn't state which sftp server you are running, my guess is that the server is running vsftpd, because it is one of very few ftp server that can serve both FTP and SFTP.

If it is running vsftpd, you'll need to edit the /etc/vsftpd.conf (or it could be in a different file in different location, especially if running virtual host). Add or change the line local_root so that it reads local_root=/var/www/site.com/public/files/. Then restart the server using service vsftpd restart. Running as root or sudoer is implied and required to make these changes. Also, don't forget to set the proper permission on the /var/www/site.com/public/files/.

otter.pro

Posted 2009-09-02T19:13:27.543

Reputation: 191

0

Set the user's home directory to /var/www/site.com/public/files and all should be well. Of course, you'll have to move the contents of his current home directory. The command for this is:

usermod -d /path/to/new/homedir/ username 

Where username is the name of the user which you are moving the home directory of.

innaM

Posted 2009-09-02T19:13:27.543

Reputation: 9 208

For the record! usermod -d /path/to/new/homedir/ username – Gabriel A. Zorrilla – 2009-09-02T19:54:02.330

Or edit /etc/passwd directly – innaM – 2009-09-02T19:58:48.670

That would not help me out, because i have the auto key files in the home/ftp, if i change the home dir, i'd have to move the key file to the public dir, which i do not want. – Gabriel A. Zorrilla – 2009-09-02T19:59:30.507

Your only other option is to configure sshd to search the public keys in another place. See man sshd_config and take a look at the AuthorizedKeysFile option. Of course this would change the location of the key files for all users whether they are using sftp or ssh itself. – innaM – 2009-09-03T09:13:53.017

0

Another option, which could be changed by the user, is to set the starting directory to /var/www/httpd in the SFTP client software directly. FileZilla, which runs on multiple platforms, has such option, and as far as I know, most SFTP client programs have such option.

jfmessier

Posted 2009-09-02T19:13:27.543

Reputation: 2 530

0

You could modify/recompile stfp-server to only use this directory and modify your sshd_config file to use this stfp-server. See Subsystem and internal-sftp options in sshd-config documentation.

fpmurphy

Posted 2009-09-02T19:13:27.543

Reputation: 1 260