Users to submit email for ftp creation


 
Thread Tools Search this Thread
Top Forums Programming Users to submit email for ftp creation
# 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 -

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
# 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:-
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
# 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:-
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
# 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?


rob
# 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
This User Gave Thanks to robertkwild For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Email the users about their existing groups

Hi Guys, I want a script where in I need to send an email to individual users about their groups. OS:unix redhat Shell :Bash. The mail should be like,"Hi &username , you are in part of &group1,&group2 .." I need to mail to their personal email id mostly @outlook. Not to their UNIX.... (1 Reply)
Discussion started by: vijay2107
1 Replies

2. UNIX for Dummies Questions & Answers

Help: Add email users in OSX terminal

Please forgive me if this is the wrong place to post. I am a VERY basic user here and have been tasked with adding a user to our email system -- we use a squirrelmail interface and I have root passwords etc. I tried logging in through a browser but get this error: ERROR: Connection dropped... (1 Reply)
Discussion started by: dperro01
1 Replies

3. Shell Programming and Scripting

Sending an email to group of users

Hi , I want to write a Unix script which can send an automatic email to the group when my job is completed.I'm trying the following Mail -s "test" <groupname> << EOD >Completed >EOD With this i'm not able to send an email to group..Any ideas? Thanks in Advance (1 Reply)
Discussion started by: BhawanaAggarwal
1 Replies

4. Shell Programming and Scripting

FTP and LOg file creation

Hello, I am new to unix , and I need to create a shell sciprt which helps me FTPing file from LAn to Unix box. These files r then processed using Perl script and put in a database. I also need to log the entire process of all the above methods in a log file in the same shell script. Like ,... (2 Replies)
Discussion started by: agarwalniru
2 Replies

5. UNIX for Dummies Questions & Answers

to send email to multiple users

hi, i'm pretty new to this unix. i've been asked to create a shell script which will pick up the email id from a text file(stored in same machine, same directory) searches for that id in another file in which a product name( a one line text) is mentioned against it. then it should send a mail... (0 Replies)
Discussion started by: vishwas.shenoy
0 Replies

6. Solaris

creation of users

Hello, I'm preparing a script for creating users automatically. I,m using this command useradd -c "Name foo" -d /export/home/my -f 10 -g other -u 10001 -s /bin/bash my the problem i have is when i create the user by command line, this acount is locked. What do i have to change in the... (2 Replies)
Discussion started by: javierg
2 Replies

7. UNIX for Dummies Questions & Answers

send email to more users

Hi, If I want to send an email to serveral users, what is the correct way to do it? I know a little bit mail command. If I want to send email to John and Scott after UNIX shell scripts have completed the job. I type: mail -s 'Job has been completed successfully' john@yahoo.com < log.txt ... (4 Replies)
Discussion started by: duke0001
4 Replies

8. UNIX for Dummies Questions & Answers

email users isssue

Hi, my email server is set up in a different machine which runs lineox enterprise 3.0. It exports /var/spool/mail to the sun server running solaris 9 and hence, all workstations nd users can access their mail. but the problem is some users cannot open their mail at all. the error "mailer... (0 Replies)
Discussion started by: stakes20
0 Replies

9. Forum Support Area for Unregistered Users & Account Problems

now 4 users created, still no email

I'm sorry for being an annoyance. I did read in another post that anyone who gives a proper email address will receive a confirmation. Well, I have created 4 accounts to no avail. Who knows, maybe I did mistype my email in one of them (twice since we have to reconfirm and with the same typo),... (3 Replies)
Discussion started by: seaghan
3 Replies

10. UNIX for Advanced & Expert Users

How to change default email sent to new users

Hello all, I have a question about the email that is sent to new users when they first check their email. The message is directly from the server and says something like "Welcome to "mailserver", you login is atypical." Where is this message? Can I change the message that is sent? Were... (2 Replies)
Discussion started by: calivw78
2 Replies
Login or Register to Ask a Question