I am working on what I thought was a very simple script to dynamically create an FTP user using 'useradd' There are several parts of this process I am unfamiliar with, and an entire day's research has not gotten me too far. Here is what I have:
password="pass"
pass=$(perl -e 'print crypt($ARGV[0], "wtf")' $password)
useradd -d HOME_DIR -s /bin/bash -g GROUP -p $pass -f -1 testing
Notes
- HOME_DIR and GROUP are placeholders
- I am not having issues with the home/base_dir (-d, -b) or group (-g) functionality of 'useradd'
Topics:
- Why are my password generation efforts not working?
- is /bin/bash the correct shell to use for a purely FTP user, or would I use /bin/false or a different shell?
- By default, useradd disables an account until they provide their own password, how do I bypass this?
- I do not want to use the passwd utility as it cripples my ability to automagically generate FTP accounts, I found a solution to this here, but I do not understand the solution
Let me know if I am going about this all wrong, or if what I am trying to do is not possible or if I am misinformed about anything I have stated herein. Thank you for any help you can provide. :D
If you want to create "FTP only" users, you should look at rssh Install rssh for your distro, and set the shell for the "FTP only" user to "/usr/bin/rssh"
Works very well
Regarding password generation:
Depending on your system, there may also be Blowfish or SHA-2 family
crypt
s as well, and it's possible that the traditional DES may be disabled for security. PAM can add its own complications in here too.That being said, the
works just fine on my system.
Regarding the shell:
/sbin/nologin
is traditional for login-disabled users. You'll have to double-check your FTP daemon's configuration to see if that excludes them from FTP access.Regarding the disabled account:
As seen above, works for me, as expected if given a working password.
About the other solution:
What don't you understand about the alternate solution? It seems very clear to me.
Just pipe "
username:password
" into "chpasswd
".If you want FTP-only users, I would recommend using a FTP daemon that supports virtual users like glftpd, Pure-FTPd, ProFTPD, vsftpd, ... actually it seems that all the common ones do. This way, an FTP account does not require a real system account.