Home Man
Today's Posts

Post questions about C, C++, Java, SQL, and other programming languages here.

Users to submit email for ftp creation


Login to Reply

Thread Tools Search this Thread
# 1  
Old 07-13-2017
Users to submit email for ftp creation

hi all,

created a bash script to create an ftp account, its here -



    echo "Enter UserName:"
    read user

    if id $user ; then
        echo "$user already exists as you can see above, please re-run the script"
        echo "$user not in system, ok to continue"

    echo "Enter Password:"
    read passwd
    echo "$user:$passwd" >> /ftp_details/accounts.csv
    echo "is this a normal user (press 1) or vfx user (press 2) ?"
    read choice
    case $choice in
            useradd -g $group -d /upload -s /sbin/nologin $user
            mkdir -p $dir/$user/upload
            chown $user:$group $dir/$user/upload
            touch $dir/$user/upload/WARNING_everything_in_here_will_get_removed_in_14_days_time.txt
            useradd $user -s /sbin/nologin -b /mnt/vfx/
            echo "invalid selection, please re-run the script"

    echo $user:$passwd | chpasswd

it works great but now i want to do something else which i dont know if possible but i will try and explain

i want the end user/customer/client or whoever submits an ftp user creation for us to send an email to sftp.molinare.co.uk and when they email it, the sftp server i created with the script will pick up what username and password they want to make the ftp account and it will create it and then send them an email saying the ftp account has been created with the username/password they gave

obviously i will configure postfix SMTP on the sftp server so it can do this


# 2  
Old 07-13-2017
Do you mean that the account they would email is sftp@....?

If the server the email is directed to has /etc/aliases then you could pass it all into a script by adding a line like this:-
sftp:     |/path/to/script

Would that help? I'm not sure who the script would run as, but you could, at least, capture the file to a spool area and have a scheduled job looking out for them that runs as a privileged account that can perform the necessary operations.

I hope that this helps,
# 3  
Old 07-13-2017
yes sorry i meant sftp@molinare.co.uk

the sftp server i will make it into a smtp server aswell ie install postfix on it

sorry i dont get your code, what do you mean by that?
# 4  
Old 07-14-2017
If the above line is added into /etc/aliases and a command newaliases is run, then any mail arriving at your server for sftp will cause the script /path/to/script to be run with the email as standard input.

You can do something dull with it, so the script could just be as short as:-
dd of=/var/spool/requests/$(date +%Y%m%d%H%M%S).$$

.... which will write the email to a timestamped (and process id) spool file that something else could be watching for.

You would still need to be able to read through the email and decipher what the request was, but then you can create the account and send them a reply fairly easily.

Does that help?
# 5  
Old 07-14-2017
ok scrap this idea, thought of another better way

im going to create a html form for this on my sftp server, so install apache on it aswell

its going to look like this -

username: text box where user types in username

password: text box where user types in password

submit button: grabs users inputs from text box's and puts it in the script and runs script

once clicked on the submit button goes to the next page and gives them this -

ftp account created with details

username: what they typed

password: what they typed

im going to have to do research into html coding so a quick google and youtube videos

what you think?

# 6  
Old 07-15-2017
I think that you should ask prospective users to apply off line for a key/token and validate that information on the request to create an account otherwise you will likely be inundated with spam accounts. Also I think that you should assign the userid and collect and correlate the user's email and phone.
# 7  
Old 07-17-2017
going to end this thread and start a new one as im not going to do it this way no more
The Following User Says Thank You to robertkwild For This Useful Post:
rbatte1 (07-18-2017)
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Email the users about their existing groups vijay2107 UNIX for Beginners Questions & Answers 1 05-21-2017 03:28 AM
Help: Add email users in OSX terminal dperro01 OS X (Apple) 1 04-20-2010 06:43 PM
Help: Add email users in OSX terminal dperro01 UNIX for Dummies Questions & Answers 1 04-08-2010 10:52 AM
Sending an email to group of users BhawanaAggarwal Shell Programming and Scripting 1 04-15-2008 11:10 AM
to send email to multiple users vishwas.shenoy UNIX for Dummies Questions & Answers 0 01-25-2008 05:00 AM
creation of users javierg Solaris 2 12-20-2007 05:11 PM
send email to more users duke0001 UNIX for Dummies Questions & Answers 4 03-21-2006 11:58 AM
email users isssue stakes20 UNIX for Dummies Questions & Answers 0 11-03-2005 05:00 PM
now 4 users created, still no email seaghan Forum Support Area for Unregistered Users & Account Problems 3 04-23-2005 05:16 PM
How to change default email sent to new users calivw78 UNIX for Advanced & Expert Users 2 01-18-2002 03:37 PM

All times are GMT -4. The time now is 06:37 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password