{"id":1279,"date":"2026-04-01T19:00:16","date_gmt":"2026-04-01T17:00:16","guid":{"rendered":"https:\/\/valentijn.sessink.nl\/?p=1279"},"modified":"2026-04-07T16:43:12","modified_gmt":"2026-04-07T14:43:12","slug":"automate-nextcloud-account-settings","status":"publish","type":"post","link":"https:\/\/valentijn.sessink.nl\/?p=1279","title":{"rendered":"Automate Nextcloud account settings"},"content":{"rendered":"\n<p>I&#8217;m setting up a couple of demo machines and I&#8217;d like Nextcloud to automatically login.<\/p>\n\n\n\n<p>Quick note to self how to do that: <br><code>occ user:add --display-name=\"Foo Bar\" --generate-password someuser4<br>occ user:auth-tokens:add -n someuser4<\/code><br>This shows something like:<br><code><strong>lDY7D3nsaZzzQVg8nvs45xwdSPhIIZDzI8QFL2vs7XI6PrpbvZJ15cJyqBCbEQL4sZDGTS9c<\/strong><\/code><br><br>Add this app password to the kdewallet under the Nextcloud folder:<br>passwords: <code>someuser4:https:\/\/nextcloud.example.com\/:0<\/code><\/p>\n\n\n\n<p>As a cli command, this means: <code>echo <strong>lDY7D3nsaZzzQVg8nvs45xwdSPhIIZDzI8QFL2vs7XI6PrpbvZJ15cJyqBCbEQL4sZDGTS9c<\/strong> | kwallet-query -f Nextcloud -w 'someuser4:https:\/\/nextcloud.example.com\/:0' kdewallet<\/code><\/p>\n\n\n\n<p>Unfortunately, this only works if the Nextcloud folder already exists. If not, <code>kwallet-query<\/code> won&#8217;t create it. In order to create a Nextcloud folder without having to insert it in a GUI interface, I came up with the following approach that is UNSAFE (no salt) but will work for demo machines.<\/p>\n\n\n\n<p>Step 0a and 0b: prepare the salt: <code>dd if=\/dev\/zero of=~\/.local\/share\/kwalletd\/kdewallet.salt bs=1 count=56<\/code>; now unpack a previously created empty blowfish encrypted wallet onto <code>kdewallet.kwl<\/code>. Yeah I know it&#8217;s messy. <a href=\"https:\/\/unix.stackexchange.com\/questions\/797469\/how-can-i-initialize-a-new-a-kde-wallet-via-the-command-line\">Here<\/a> is a Stackexchange question that didn&#8217;t get an answer for 6+ months. But hey, it may change and if this blog posting doesn&#8217;t reflect it, you&#8217;re lucky and I&#8217;m not.<\/p>\n\n\n\n<p>Anyway, step 1: we&#8217;ll use a Python script to add the app password. Install <code>python3-keyring<\/code> (with <code>apt<\/code> or <code>pip<\/code>) and do, as a logged in user:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import keyring<br>keyring.set_keyring(next((bk for bk in keyring.backend.get_all_keyring() if bk.name == 'kwallet DBusKeyring'), None))<br>keyring.set_password('Nextcloud', 'someuser4:https:\/\/nextcloud.example.com\/:0', 'lDY7D3nsaZzzQVg8nvs45xwdSPhIIZDzI8QFL2vs7XI6PrpbvZJ15cJyqBCbEQL4sZDGTS9c')<\/pre>\n\n\n\n<p>This will work, even if the Nextcloud folder does not yet exist. Please note that you do need the kwalletd6 running, i.e. you need an actual kde session with an actual user to do this. I implemented it with a <code>~\/.config\/autostart\/somethingsomething.desktop<\/code> file, so the app password is re-added every session.<\/p>\n\n\n\n<p>Now add a config to ~\/.local\/Nextcloud\/nextcloud.cfg that includes someuser4 as username.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m setting up a couple of demo machines and I&#8217;d like Nextcloud to automatically login. Quick note to self how to do that: occ user:add &#8211;display-name=&#8221;Foo Bar&#8221; &#8211;generate-password someuser4occ user:auth-tokens:add -n someuser4This shows something like:lDY7D3nsaZzzQVg8nvs45xwdSPhIIZDzI8QFL2vs7XI6PrpbvZJ15cJyqBCbEQL4sZDGTS9c Add this app password to the kdewallet under the Nextcloud folder:passwords: someuser4:https:\/\/nextcloud.example.com\/:0 As a cli command, this means: echo lDY7D3nsaZzzQVg8nvs45xwdSPhIIZDzI8QFL2vs7XI6PrpbvZJ15cJyqBCbEQL4sZDGTS9c&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[9,203],"class_list":["post-1279","post","type-post","status-publish","format-standard","hentry","category-happy-hacking","tag-linux","tag-nextcloud"],"_links":{"self":[{"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/posts\/1279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1279"}],"version-history":[{"count":6,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/posts\/1279\/revisions"}],"predecessor-version":[{"id":1288,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=\/wp\/v2\/posts\/1279\/revisions\/1288"}],"wp:attachment":[{"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/valentijn.sessink.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}