Virtual Hosting With vsftpd And PostgreSQL
Virtual Hosting With vsftpd And PostgreSQLThis document describes how to install a vsftpd server that uses virtual users from a PostgreSQL database instead of real system users. I couldn't find any tutorial like that on the internet, so when that configuration finally worked for me, I decided to publish it. The documentation is based on FreeBSD 6.2 which I was recently forced to use (I usually use Debian). Nevertheless the document should be suitable for almost any Linux distribution as well (may require very small amendments). OK, let's start. Required Packages
Installation1. PostgreSQL#cd /usr/ports/database/postgresql-server82 Set your postgres locale before initdb: #vi /usr/local/pgsql/.cshrc: setenv PGLIB /usr/local/lib Install db cluster with right encoding (taken from LC_ALL): su - pgsql
2. PAM-PGSQLcd /usr/ports/security/pam-pgsql Make sure that pam-pgsql.so is in /usr/lib. If you get SEGFAULT most likely pam_pgsql is not in the right path (I encountered that problem when I tried pam_pwdfile). ls /usr/lib/pam_pgsql.so /usr/lib/pam_pgsql.so 3. vsftpdcd /usr/ports/ftp/vsftpd
4. And Now ... Working Examples Of Configuration Filesvsftpd - is the name of the pam config file /etc/pam.d/vsftpd. vsftpd - is the name of recently added user (the user needs write access rights to localroot from the example local_umask=0000 - I wanted files to be stored with chmod 77x). #vi /usr/local/etc/vsftpd.conf: By default pam_pgsql is looking for the configuration in the file /etc/pam_pgsql.conf. I might think of a setup where I authenticate different services vs. different tables in the postgres database. The config_file switch does the job - this is how the file looks: #vi /etc/pam.d/vsftpd: #vi /usr/local/pgsql/data/pg_hba.conf: #vi/etc/pam_pgsql_vsftpd.conf: #su - pgsql Welcome to psql 8.2.4, the PostgreSQL interactive terminal. system=# CREATE TABLE "accounts"( NOTICE: CREATE TABLE will create implicit sequence "accounts_i_id_seq" for serial column "accounts.i_id" system=# insert into accounts(s_username, s_password) values('testuser',md5('secret_pass')); INSERT 0 1 system=# select * from accounts; i_id | s_username | s_password | b_expired Let's create a folder for our new virtual user: mkdir /usr/local/www/apache22/data/testuser Let's start vsftpd on system startup: #vi /usr/local/etc/rc.d/vsftpd: Let's start vsftpd right now: #/usr/local/etc/rc.d/vsftpd ... and vsftpd should work fine now. I am aware that some things might be done in a different way, but this document should be good enough to guide you.
|






Recent comments
4 hours 8 min ago
5 hours 1 min ago
5 hours 5 min ago
6 hours 57 min ago
9 hours 8 min ago
9 hours 54 min ago
10 hours 10 min ago
13 hours 8 min ago
14 hours 40 min ago
16 hours 57 min ago