Unix/Linux Go Back    


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

Users to submit email for ftp creation

Programming


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-13-2017   -   Original Discussion by robertkwild
robertkwild's Unix or Linux Image
robertkwild robertkwild is offline
Registered User
 
Join Date: Apr 2016
Last Activity: 21 November 2017, 9:05 AM EST
Posts: 83
Thanks: 9
Thanked 8 Times in 6 Posts
Users to submit email for ftp creation

hi all,

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


Code:
#!/bin/bash

dir=/mnt/sftp
group=sftp_users

    echo "Enter UserName:"
    read user

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

    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
        1)
            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
            ;;
        2)
            useradd $user -s /sbin/nologin -b /mnt/vfx/
            ;;
        *)
            echo "invalid selection, please re-run the script"
            exit
            ;;
    esac

    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

cheers,

rob
Sponsored Links
    #2  
Old Unix and Linux 07-13-2017   -   Original Discussion by robertkwild
rbatte1's Unix or Linux Image
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 13 December 2017, 7:43 AM EST
Location: Lancashire, UK
Posts: 3,407
Thanks: 1,477
Thanked 669 Times in 602 Posts
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:-
Code:
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,
Robin
Sponsored Links
    #3  
Old Unix and Linux 07-13-2017   -   Original Discussion by robertkwild
robertkwild's Unix or Linux Image
robertkwild robertkwild is offline
Registered User
 
Join Date: Apr 2016
Last Activity: 21 November 2017, 9:05 AM EST
Posts: 83
Thanks: 9
Thanked 8 Times in 6 Posts
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 Unix and Linux 07-14-2017   -   Original Discussion by robertkwild
rbatte1's Unix or Linux Image
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 13 December 2017, 7:43 AM EST
Location: Lancashire, UK
Posts: 3,407
Thanks: 1,477
Thanked 669 Times in 602 Posts
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:-
Code:
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?
Robin
Sponsored Links
    #5  
Old Unix and Linux 07-14-2017   -   Original Discussion by robertkwild
robertkwild's Unix or Linux Image
robertkwild robertkwild is offline
Registered User
 
Join Date: Apr 2016
Last Activity: 21 November 2017, 9:05 AM EST
Posts: 83
Thanks: 9
Thanked 8 Times in 6 Posts
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?


rob
Sponsored Links
    #6  
Old Unix and Linux 07-15-2017   -   Original Discussion by robertkwild
jgt's Unix or Linux Image
jgt jgt is offline Forum Advisor  
Registered User
 
Join Date: Apr 2007
Last Activity: 13 December 2017, 7:58 AM EST
Location: 44.21.48N 80.50.15W
Posts: 2,014
Thanks: 2
Thanked 275 Times in 257 Posts
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.
Sponsored Links
    #7  
Old Unix and Linux 07-17-2017   -   Original Discussion by robertkwild
robertkwild's Unix or Linux Image
robertkwild robertkwild is offline
Registered User
 
Join Date: Apr 2016
Last Activity: 21 November 2017, 9:05 AM EST
Posts: 83
Thanks: 9
Thanked 8 Times in 6 Posts
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)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 04:28 AM
creation of users javierg Solaris 2 12-20-2007 06:11 PM
send email to more users duke0001 UNIX for Dummies Questions & Answers 4 03-21-2006 12:58 PM
email users isssue stakes20 UNIX for Dummies Questions & Answers 0 11-03-2005 06:00 PM
now 4 users created, still no email seaghan Forum Support Area for Unregistered Users & Account Problems 3 04-23-2005 06:16 PM



All times are GMT -4. The time now is 12:23 AM.