OCC add:user from csv file shell script


I’ve installed owncloud on OVH VPS.
I try to import users from a csv file. I wrote a shell script for that. I would like to import users with only email (no password) so that an email is sent to them for creating their password.

According to documentation :

A password is not required , if an email address is provided. If a password is not provided, a temporary one will be generated. It cannot be set to 0 .

here is the shell script i wrote :

while IFS=, read -r username displayname email group1 group2
  echo "création de l'utilisateur $username avec l'email $email displayname $displayname group1 $group1 group2 $group2"
  sudo -u www-data php /var/www/owncloud/occ user:add --display-name "$displayname" --email $email --group "$group1" --group "$group2" $username
done < users.csv

Steps to reproduce

  1. execute script : sh ./script.sh

Expected behaviour

users should be created

Actual behaviour

password is asked for user

Server configuration

Operating system: Debian 10

Web server: apache 2


PHP version: 7.4.24

ownCloud version:


No answer ? Did i forget to put something to explain my issue ?
Please help…


I cannot help, unfortunately. I think the documentation doesn’t match the real situation here, the password request cannot be avoided.

So it’s not possible to create users with only email (no password) with occ and then an invitation email is sent to them to choose their password ?
We must use web interface for this scenario ?

Hi fredleput,

after having reviewed the code I can confirm this option is not possible with the occ command. You may open a feature request at https://github.com/owncloud/core/issues/

As a workaround you could create a user with a random password, generate a password recovery link and send this in a custom email to your user, I.e.

$ export OC_PASS=verysecurepassword; sudo -E -u www-data php occ user:add --password-from-env --email exampleuser@example.com exampleuser
The user "exampleuser" was created successfully
Email address set to "exampleuser@example.com"

$ sudo -u www-data php occ user:resetpassword --output-link exampleuser
The password reset link is: http://owncloud/index.php/lostpassword/reset/form/3C7ifE8m7edEQ82bKPAU2/exampleuser


1 Like

Works like a charm if you use --send-email :
sudo -u www-data php occ user:resetpassword --send-email sampleuser

Thx a lot !

1 Like

I was aware about the send-email switch as well but your users might get confused when they receive a password reset email. So I offered the variant where you retrieve the link only which you could embed in a proper template.

Anyway, I’m glad this works for you :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.