jeudi 29 janvier 2015

Setting up a script on an AMI box to create directories - vsftpd, pam, mysql


I'd like to first say I'm a noob when it comes to linux, so please excuse my confusion. I'm trying to setup vsftpd on a amazon ami 64 bit box, free tier micro. Following these instructions, http://ift.tt/15WIZgT 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.


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://ift.tt/1EsmaRl


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


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.


http://ift.tt/15WJ1oV


Thanks in advance.



Aucun commentaire:

Enregistrer un commentaire