script create user

zapeador

Member
Joined
Jan 15, 2022
Messages
44
Reaction score
13
Credits
401
Hello, I am with a script that creates a user and does a series of other things and I need that same user that is saved in the $user variable to be created on another machine and create a quota

I don't know if I should do it by scp, ssh or how to execute part of the script in another remote machine

I also thought in that machine2 to make a small script that is called from machine1 but I still don't know how to pass the variable that is the name of the user to create
 


How many remote machines do you have to do this on?
If it was me, I would do it in ansible.
 
How many remote machines do you have to do this on?
If it was me, I would do it in ansible.
every time I create a user, I have to create the user and give him a quota, users are not created every day but I want the script to do it although I cannot get how
 
every time I create a user, I have to create the user and give him a quota, users are not created every day but I want the script to do it although I cannot get how

quota's are typically done by filesystems (directories) not by user.

To automatically add a user in a script...

#!/usr/bin/bash
user="jacksparrow"
password="L0t$aG0ld"
useradd $user
echo $user:$password | chpasswd


... that will also set their password.

Filesystem quotas are slightly different per distro.


 
A quick down and dirty way would be something like this.

#! /bin/bash
echo -n "IP: "
read IP
echo -n "User: "
read user
echo -n "Password: "
read password
ssh $IP useradd $user
 


Top