CentOSThis forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i have created a ftps server using vsftpd and it works a treat
atm to create a user/password/home dir i do these two command -
useradd test -d /mnt/data/test
passwd test
also i have another dir that i use for home dirs, which is using a nfs location (vfx_ftp) and not the local sdb1 (data)
useradd test1 -d /mnt/vfx_ftp/test1
passwd test1
how can i make this into a script ie so it asks if its for a vfx ftp or local ftp and also so it appends a file eachtime with the username and password so incase someone forgets the password for thier ftp i can look at the file and tell them
You can use either command line arguments or use read to prompt for home and name. Although you can use a file to save names and passwords typically the standard procedure is to reset to some predefined password and force the user to change at login.
hi all,
i have created a ftps server using vsftpd and it works a treat atm to create a user/password/home dir i do these two command -
useradd test -d /mnt/data/test
passwd test
also i have another dir that i use for home dirs, which is using a nfs location (vfx_ftp) and not the local sdb1 (data)
useradd test1 -d /mnt/vfx_ftp/test1
passwd test1
how can i make this into a script ie so it asks if its for a vfx ftp or local ftp and also so it appends a file eachtime with the username and password so incase someone forgets the password for thier ftp i can look at the file and tell them
Please, don't just keep asking for scripts/handouts, without showing any effort on your part. There are MANY bash-scripting tutorials you can find, and have been directed to in the past, that you can reference to get started. We're happy to help you if you're stuck, but show what you've done first.
#!/bin/bash
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
useradd $user -s /sbin/nologin -b /mnt/data/
touch /mnt/data/$user/files_will_get_deleted_older_than_14_days_old.txt
echo $user:$passwd | chpasswd
#!/bin/bash
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 (1) or vfx user (2) ?"
read dir
case $dir in
1)
useradd $user -s /sbin/nologin -b /mnt/data/
touch /mnt/data/$user/files_will_get_deleted_older_than_14_days_old.txt
;;
2)
useradd $user -s /sbin/nologin -b /mnt/vfx/
;;
esac
echo $user:$passwd | chpasswd
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.