Script to create a linux user on one server, when a DB user is made on another?

Hello all,
    I am looking for a way to have a linux user created on a sFTP gateway automatically with the credentials that were used when a user was created in a database. We have a web application in which we onboard a user and create their account. We would then have to go and manually create a linux user on the sFTP gateway, as it uses standard linux users as the credentials to login to FTP.

Is there a script (perhaps bash or python?) that can either use some sort of trigger to know when a DB user is made, then create a user on the FTP server. If it can use the same credentials that would be ideal, but if not, it can create a random password and then we can have it email it to the user perhaps. If there is nothing made already, if someone could point me in the right direction as to the best way to go about this, or what language would be ideal, please do.

MostHatedIT ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
This will be a custom script based on your environment.

You'll just fire off ssh + command to create new user on your SFTP gateway machine.

You'd fire off your ssh command each time you onboard a new database user.

You might go one step further + run a nightly CRON job to check all database users against SFTP gateway users + notify someone if there's a mismatch, which means your ssh command failed.
Erik SchminkeAIX/Linux Systems AdministratorCommented:
Depending on which database you're using, you might be able to drive execution of the adduser command from a database event.

I've not tested this, so your mileage may vary... but this page appears to demonstrate how to make a "CREATE TRIGGER" that will execute a system command from a MySQL database.

Once you have a new record firing a system command, you can easily create a script that makes the appropriate adduser command.

If the adduser script needs to be execute command on a remote system, you could use SSH keys for that.

Solving those general problems in that order should get you to where you want to be.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MostHatedIT ManagerAuthor Commented:
Thanks for the info. I actually ended up doing something very close to that just before you replied. All s well. : )
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.