+6

pureFTP add additional users

janxb fa 5 anys actualitzat fa 5 anys 19
Could you add the ability to create additional FTP-users using ajenti?
For example, we have a webcam upload, but we don't want to expose our main web root to this upload user, so we want to create a new user who has only access to a subfolder..

For now, I create the user using the "pure-pw" command, but it gets overwritten when ajenti updates the website config.
One more thing: We are using the ajenti-v-ftp-pureftpd plugin..
Important Information for all people who want to use my script:
1. Here is an updated version on github: https://gist.github.com/janxb/5e26afdeed3f42a6bdab
2. The process name you have to add in ajenti must not contain spaces. The best name for example is "ftpusers"..
Never mind, I found a solution: Create the following script and add it under "processes" in the existing website.
The users are input in format username:password:homepath

#!/bin/bash
SET_USERS="usernameone:password:/path/to/web/folder usernametwo:password:/path/to/second/folder"

IFS=' ' read -a USERS <<< "${SET_USERS}"

for SET_USER in ${USERS[@]}; do
IFS=':' read -a USER <<< "${SET_USER}"
NAME=${USER[0]};
PASS=${USER[1]};
DIR=${USER[2]};
(echo $PASS; echo $PASS) | pure-pw useradd $NAM -u www-data -g www-data -d $DIR
done
pure-pw mkdb

sleep 1;
exit;

Could you please go into detail on how to use this?

I saved the script with corresponding changes to a new directory I created, then added the script under the "processes" tab for the website I want additional FTP users for. This does not work, am I missing something? I have even tried creating the user first in Ajenti, restarting the website/Ajenti/server.
At first, there is a typo in my script above. Please use the script i have published on github for you: https://gist.github.com/janxb/5e26afdeed3f42a6bdab

After creating and modifying the script, you have to save (i have saved mine as /usr/local/bin/scripts/add_ftp_users.sh)
The following screenshot may show it better:



Please feel free to make further comments if anything is unclear. :)
Still having problems with the new script. I have copied your setup exactly, down to the directory, but still unable to login via FTP or SFTP with new user.

Status: Connecting to 46.29.19.59...
Response: fzSftp started, protocol_version=2
Command: open "diak@46.29.19.59" 22
Command: Pass: ************
Error: Authentication failed.
Error: Critical error: Could not connect to server
Status: Disconnected from server
Status: Connecting to 46.29.19.59:21...
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Command: USER diak
Response: 331 User diak OK. Password required
Command: PASS ************
Response: 530 Login authentication failed
Error: Critical error: Could not connect to server
Ah, I forgot to mention that you have to restart your websites in the website overview.
You can also look under the "supervisor" section in the left sidebar if your added process is listed as "running".
Still a no go. Shouldn't the script actually start with #!/bin/bash? Regardless, it doesn't work.
Yes, i corrected it on github. What is shown on the supervisor section?
Hm, my section is showing the process uptime right next to its name. You could try pressing the restart button on top of the supervisor section. For reference, this is how it looks like in my panel:



Did not help. "/var/log/ajenti.log" shows services in supervisor have been started or force-reloaded but no errors. The process does not seem to be starting. I have also run chmod +x add_ftp_users.sh, hoping it would solve my problems.
Here is an error I get. User "diak" does not exist and "/etc/pure-ftpd/pureftpd.passwd.tmp" exists with 777 permissions even.

user@serv019059 /u/l/b/scripts> sudo ./add_ftp_users.sh
Password:
Enter it again:
Error.
Check that [diak] doesn't already exist,
and that [/etc/pure-ftpd/pureftpd.passwd.tmp] can be written.
they: option requires an argument -- 'd'
please execute the command "pure-pw list" and show me its output. It looks like the user is existing.
Do you have a colon or any other special character in one of your ftp user passwords?

And some more thing: What does the last line "they: option requires an argument" mean?
"pure-pw list" outputs nothing, run with sudo and as su.

As for "they..." it's the name of my second user.
SET_USERS="diak:sdf2rsdf:/srv/site0 they:sf2rdf:/srv/site1"

I have removed the second option all together but still gives me the first error.

SET_USERS="diak:sdf2rsdf:/srv/site0"
The command is "pure-pw list".
BTW: What operating system are you using?
Maybe we should not chat here in the comments.. Do you have a google account, so that we can write by hangouts?
That was a typo on here. I am running Debian. And yes, please add ********@gmail.com

Thank you for your help!
Problem was solved. Process name must not contain spaces. I have updated my comment above with additional information.