Bulk setting of application password

Tell me how I can create the same application password for the Desktop Client in bulk.

Can you elaborate on your use case?

I want execute command like “for I in {usr1,user2,etc} ; do occ user:add-app-password $i; done”, and enter password for all users in $i

The following should work. However, only one user can be added to the command at a time:

export NC_PASS="password123"
sudo -E -u www-data bash -c "php /var/www/nextcloud/occ user:add-app-password --password-from-env <user>"

In order to run the command for multiple users at once, you could script something with bash, although I wouldn’t recommend it. For security reasons, it is not a good idea to create the same app password for all users.

Although I still wouldn’t recommend it, I came up with the following script, and it works. However, I have not tested if connecting an app with the respective password actually works:

Create a list of usernames in a file usernames.txt, as follows:


and then you could try running the following script, but try it with some test users first! :wink:


# Export the password
export NC_PASS="password123"

# Path to the usernames file

# Loop through each username in the file
while IFS= read -r USERNAME; do
  if [[ -n "$USERNAME" ]]; then
    echo "Adding app password for user: $USERNAME"
    sudo -E -u www-data bash -c "php /var/www/nextcloud/occ user:add-app-password --password-from-env ${USERNAME}"
1 Like

Thanks! It’s good idea.