Emulate console input.

The goal is to create an FTP user using php exec() – the script is already rooted.

useradd user1 -p user1 -d /home/user1

The user is created fine, the directory is in place, but… vsftpd doesn’t see it (the user). No way.
Sees only if created via adduser.

adduser user1

This is followed by entering the password twice and the rest of the data. But in one line (read: so that it could be done through exec () such a command is impossible.

The only thing that comes to mind is to emulate the password input.
Do not advise changing to proftpd.

So, are there any ways to emulate text input into the console using bash or, in extreme cases, php?

Answer 1, authority 100%

The useraddprogram does not set a password for a newly created user. therefore, under this name it is impossible to “log in” – neither via the ftpprotocol, nor in any other way.

you can set/change the user(s) password(s) non-interactively, for example, using the program chpasswd:

$ echo : | chpasswd

Leave a reply

Please enter your comment!
Please enter your name here