Shell script - craete user/password/home dir
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 many thanks, rob |
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.
|
Quote:
http://www.linuxquestions.org/questi...se-4175592277/ http://www.linuxquestions.org/questi...rm-4175576984/ http://www.linuxquestions.org/questi...es-4175574055/ http://www.linuxquestions.org/questi...es-4175572502/ 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. |
getting close -
#!/bin/bash echo "Enter UserName:" read user echo "Enter Password:" read passwd echo "$user:$passwd" >> /ftp.txt useradd $user -b /mnt/data/ echo $user:$passwd | chpasswd |
i have made it to a T now -
#!/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 |
Code:
#!/bin/bash |
All times are GMT -5. The time now is 07:16 AM. |