I'm trying to setup vsftpd on a amazon ami 64 bit box, free tier micro.
Following these instructions, http://wiki.centos.org/HowTos/VirtualVsFtpd I have successfully been able to get my ftp up and running. As long as I manually create the users home directory, it works perfectly.
Need need help automatically setting up user home directories. for the ftp client
The next thing I wanted to do is setup a script to automatically setup the users home directory rather than manually having to do it. I found some documentation here, http://t3chnick.blogspot.com/2011/12/vsftp-mysql-virtual-with-auto-create.html I have spent hours trying to get this to work without any success.
Like nicks documentation I modified my
/etc/pam.d/vsftpd file to include the following lines of code.
#%PAM-1.0 session optional pam_keyinit.so force revoke # Auth in MySQL auth requisite pam_mysql.so user=vsftpd-ro passwd=readonly host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=0 auth required pam_script.so onerr=success dir=/etc/pam-script**
Now my confusion
Because of my lack of knowledge, I'm not sure if I'm suppose to be creating the script file or if it's already included on the box and I just need to modify it. I'm assuming when Nick posted his example, he created the script on a 32bit box, but at the bottom of his article he talks about a 64bit script.
Anyhow when I try to navigate to
$ cat /etc/pam-script/pam_script_auth I'm finding neither the script nor the
pam-script dir exist. If I attempt to create it I get a permission denied error unless I use
sudo vi /etc/pam-script/pam_script_auth
Now once again, I'm not sure manually creating the script is the correct way to go about this. I'm not sure if I should be downloading something, or if in a 64bit box if their is an existing script else where that needs to be modified. Anyhow after manually creating it and giving permissions to the script to read, write, execute, I end up with this.
$ cat /etc/pam-script/pam_script_auth
#!/bin/sh if [ ! -d "/opt/ftp/$PAM_USER" ]; then /usr/bin/env mkdir /opt/ftp/$PAM_USER /usr/bin/env chown ftp:ftp /opt/ftp/$PAM_USER fi
Now I'm able to still log into the box, but it appears to fail to authenticate against the db and I'm not seeing where the user file has been created. I'm guessing their is something wrong with the script. I also found the following ubuntu question where nick replied to a similar question.
Thanks in advance.
It was suggested by jayhendren to use pam_mkhomedir.so rather than a script.
Please correct me if I'm wrong, but my assumption is to configure my
/etc/pam.d/vsftpd like so
#%PAM-1.0 session optional pam_keyinit.so force revoke # Auth in MySQL auth requisite pam_mysql.so user=vsftpd-ro passwd=readonly host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=0 session required pam_mkhomedir.so skel=/opt/ftp/ umask=0022 debug account required pam_mysql.so user=vsftpd-ro passwd=readonly host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=0
Could someone verify this configuration?