[SOLVED] How to use correctly nextcloudcmd?

Nextcloud version : 20.0.5
Operating system and version: LXC debian 10
Apache or nginx version _: Apache/2.4.38
PHP version : 7.4.14

The issue you are facing:
I can not connect to my local NC instance; it runs very well with synchronization active with my android phone [file,calendar,contact] and my laptop with gnome [file,calendar,contact] . the username and password is accepted by the NC server; i have trouble when i try to connect a LXC instance to NC server via the tool nextcloudcmd.
The IP, username and password is the same of the other successful connection but it s not work; a get a strange error like it can not connect for a permission issue; how can i fix it?

Is this the first time you’ve seen this error? Y

Steps to replicate it:

  1. full NC server up and running
  2. create a normal user
  3. try to connect via nextcloudcmd tool

The output of your NextcloudCMD:

root@DOCUMENTS:~# nextcloudcmd --logdebug --user $$USER$$ --password $$PASSWORD$$ /root/IMPORT $$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati
01-18 13:30:09:275 [ info nextcloud.sync.accessmanager ]:	2 "" "$$NC_IP_HTTPS$$/nextcloud/ocs/v1.php/cloud/capabilities?format=json" has X-Request-ID "1433160f-e1ba-4866-8161-a9a748f54344"
01-18 13:30:09:276 [ info nextcloud.sync.networkjob ]:	OCC::JsonApiJob created for "$$NC_IP_HTTPS$$/nextcloud" + "ocs/v1.php/cloud/capabilities" ""
01-18 13:30:09:279 [ info nextcloud.sync.networkjob ]:	Redirecting "GET" QUrl("$$NC_IP_HTTPS$$/nextcloud/ocs/v1.php/cloud/capabilities?format=json") QUrl("$$NC_IP_HTTPS$$/nextcloud/ocs/v1.php/cloud/capabilities?format=json")
01-18 13:30:09:280 [ info nextcloud.sync.accessmanager ]:	2 "" "$$NC_IP_HTTPS$$/nextcloud/ocs/v1.php/cloud/capabilities?format=json" has X-Request-ID "84c612dc-19c7-4f53-926d-052a6bf35ac2"
01-18 13:30:09:330 [ info nextcloud.sync.account ]:	"SSL-Errors happened for url  \"$$NC_IP_HTTPS$$/nextcloud/ocs/v1.php/cloud/capabilities?format=json\" \tError in  QSslCertificate(\"3\", \"d4:db:6c:57:c5:e7:53:b5\", \"cANpWfX28yFyyRCcRzhfYQ==\", (), (), QMap((1, \"NEXTCLOUD\")(1, \"nextcloud.lan\")(1, \"NEXTCLOUD.nextcloud.lan\")), QDateTime(2018-02-06 17:01:44.000 UTC Qt::TimeSpec(UTC)), QDateTime(2028-02-06 17:01:44.000 UTC Qt::TimeSpec(UTC))) : \"The host name did not match any of the valid hosts for this certificate\" ( \"The host name did not match any of the valid hosts for this certificate\" ) \n \tError in  QSslCertificate(\"3\", \"d4:db:6c:57:c5:e7:53:b5\", \"cANpWfX28yFyyRCcRzhfYQ==\", (), (), QMap((1, \"NEXTCLOUD\")(1, \"nextcloud.lan\")(1, \"NEXTCLOUD.nextcloud.lan\")), QDateTime(2018-02-06 17:01:44.000 UTC Qt::TimeSpec(UTC)), QDateTime(2028-02-06 17:01:44.000 UTC Qt::TimeSpec(UTC))) : \"The certificate is self-signed, and untrusted\" ( \"The certificate is self-signed, and untrusted\" ) \n " Certs are known and trusted! This is not an actual error.
01-18 13:30:10:180 [ info nextcloud.sync.networkjob ]:	Redirecting "GET" QUrl("$$NC_IP_HTTPS$$/nextcloud/ocs/v1.php/cloud/capabilities?format=json") QUrl("$$NC_IP_HTTPS$$/index.php/apps/dashboard/")
01-18 13:30:10:180 [ info nextcloud.sync.accessmanager ]:	2 "" "$$NC_IP_HTTPS$$/index.php/apps/dashboard/" has X-Request-ID "549df720-dc99-4a8f-abec-6de337d15615"
01-18 13:30:10:466 [ info nextcloud.sync.networkjob.jsonapi ]:	JsonApiJob of QUrl("$$NC_IP_HTTPS$$/index.php/apps/dashboard/") FINISHED WITH STATUS "OK"
01-18 13:30:10:466 [ warning nextcloud.sync.networkjob.jsonapi ]:	invalid JSON! "<!DOCTYPE html>\n<html class=\"ng-csp\" data-placeholder-focus=\"false\" lang=\"it\" data-locale=\"it_IT\" >\n\t<head data-user=\"$$USER$$\" data-user-displayname=\"1point61803\" data-requesttoken=\"NTdD7Yjl8WCuxcCSkBjaIdDR3kxtOaHAvsMuwT4aB5c=:cFkEivvWiVbh/e/k2H/vb5ekrh4/U8u00qlGuGpuQaM=\">\n\t\t<meta charset=\"utf-8\">\n\t\t<title>\n\t\t\tCruscotto - Nextcloud\t\t</title>\n\t\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, minimum-scale=1.0\">\n\t\t\t\t<meta name=\"apple-itunes-app\" content=\"app-id=1125420102\">\n\t\t\t\t<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n\t\t<meta name=\"apple

CUT CUT CUT CUT

?requesttoken=NTdD7Yjl8WCuxcCSkBjaIdDR3kxtOaHAvsMuwT4aB5c%3D%3AcFkEivvWiVbh%2Fe%2Fk2H%2Fvb5ekrh4%2FU8u00qlGuGpuQaM%3D\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<img alt=\"\" src=\"/core/img/actions/logout.svg?v=8a95488e\">\n\t\t\t\t\t\t\t\tEsci\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t</nav>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</header>\n\n\t\t<div id=\"sudo-login-background\" class=\"hidden\"></div>\n\t\t<form id=\"sudo-login-form\" class=\"hidden\" method=\"POST\">\n\t\t\t<label>\n\t\t\t\tQuesta azione richiede la conferma della tua password<br/>\n\t\t\t\t<input type=\"password\" class=\"question\" autocomplete=\"new-password\" name=\"question\" value=\" \"\n\t\t\t\tplaceholder=\"Conferma la tua password\" />\n\t\t\t</label>\n\t\t\t<input class=\"confirm\" value=\"Conferma\" type=\"submit\">\n\t\t</form>\n\n\t\t<div id=\"content\" class=\"app-dashboard\" role=\"main\">\n\t\t\t<div id=\"app-content-vue\"></div>\n\t\t</div>\n\n\t</body>\n</html>\n" "illegal value"
01-18 13:30:10:467 [ debug default ]	[ main(int, char**)::<lambda ]:	Server capabilities QJsonObject()
01-18 13:30:10:765 [ info nextcloud.sync.database ]:	sqlite3 version "3.27.2"
01-18 13:30:10:765 [ info nextcloud.sync.database ]:	sqlite3 journal_mode= "wal"
01-18 13:30:10:766 [ info nextcloud.sync.engine ]:	There are 5924155392 bytes available at "/root/IMPORT/"
01-18 13:30:10:766 [ info nextcloud.sync.engine ]:	Sync with existing sync journal
01-18 13:30:10:923 [ info nextcloud.sync.engine ]:	"Using Qt 5.11.3 SSL library OpenSSL 1.1.1d  10 Sep 2019 on Debian GNU/Linux 10 (buster)"
01-18 13:30:10:923 [ info nextcloud.sync.engine ]:	NOT Using Selective Sync
01-18 13:30:10:923 [ info nextcloud.sync.engine ]:	#### Discovery start ####################################################
01-18 13:30:10:924 [ info nextcloud.sync.engine ]:	Server "" 
01-18 13:30:10:924 [ info sync.csync.utils ]:	Memory: 384252K total size, 26012K resident, 22952K shared
01-18 13:30:10:924 [ info sync.csync.csync ]:	## Starting local discovery ##
01-18 13:30:10:924 [ info nextcloud.sync.csync.updater ]:	._sync_425bf4ee1646.db excluded  (1)
01-18 13:30:10:925 [ info nextcloud.sync.csync.updater ]:	Checking for rename based on inode # 154900
01-18 13:30:10:925 [ info nextcloud.sync.csync.updater ]:	file: .Contacts-Backup, instruction: INSTRUCTION_NEW <<=
01-18 13:30:10:963 [ info nextcloud.sync.csync.updater ]:	.Contacts-Backup/.2018-02-24_09-12-45.vcf.~21dc443c excluded  (2)
01-18 13:30:10:963 [ info nextcloud.sync.csync.updater ]:	.Contacts-Backup/.2018-02-26_06-45-39.vcf.~2c265f65 excluded  (2)
01-18 13:30:10:963 [ info nextcloud.sync.csync.updater ]:	 <= Closing walk for /root/IMPORT/.Contacts-Backup with read_from_db 0
01-18 13:30:10:963 [ info nextcloud.sync.csync.updater ]:	._sync_20797bc0e015.db-shm excluded  (1)
01-18 13:30:10:963 [ info nextcloud.sync.csync.updater ]:	._sync_6437450207c6.db excluded  (1)
01-18 13:30:10:963 [ info nextcloud.sync.csync.updater ]:	._sync_b3ae046e61bd.db excluded  (1)
01-18 13:30:10:963 [ info nextcloud.sync.csync.updater ]:	._sync_be711f0f58f2.db excluded  (1)
01-18 13:30:10:963 [ info nextcloud.sync.csync.updater ]:	._sync_2b00f5725bd4.db excluded  (1)
01-18 13:30:10:963 [ info nextcloud.sync.csync.updater ]:	._sync_be711f0f58f2.db-shm excluded  (1)
01-18 13:30:10:964 [ info nextcloud.sync.csync.updater ]:	._sync_20797bc0e015.db excluded  (1)
01-18 13:30:10:964 [ info nextcloud.sync.csync.updater ]:	._sync_b825684c46ca.db excluded  (1)
01-18 13:30:10:964 [ info nextcloud.sync.csync.updater ]:	._sync_be711f0f58f2.db-wal excluded  (1)
01-18 13:30:10:964 [ info nextcloud.sync.csync.updater ]:	._sync_20797bc0e015.db-wal excluded  (1)
01-18 13:30:10:964 [ info nextcloud.sync.csync.updater ]:	._sync_6c52106081a4.db excluded  (1)
01-18 13:30:10:964 [ info nextcloud.sync.csync.updater ]:	 <= Closing walk for /root/IMPORT with read_from_db 0
01-18 13:30:10:964 [ info sync.csync.csync ]:	Update detection for local replica took 0.039 seconds walking 1 files
01-18 13:30:10:964 [ info sync.csync.utils ]:	Memory: 384252K total size, 26012K resident, 22952K shared
01-18 13:30:10:964 [ info sync.csync.csync ]:	## Starting remote discovery ##
01-18 13:30:10:965 [ info nextcloud.sync.accessmanager ]:	6 "PROPFIND" "$$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati" has X-Request-ID "c44e970d-8a93-427c-9c6c-59bc1ee06a6e"
01-18 13:30:10:965 [ info nextcloud.sync.networkjob ]:	OCC::LsColJob created for "$$NC_IP_HTTPS$$/nextcloud" + "/Importati" "OCC::DiscoverySingleDirectoryJob"
01-18 13:30:10:966 [ info nextcloud.sync.networkjob ]:	Redirecting "PROPFIND" QUrl("$$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati") QUrl("$$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati")
01-18 13:30:10:966 [ info nextcloud.sync.accessmanager ]:	6 "PROPFIND" "$$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati" has X-Request-ID "5b86486e-428f-4c1f-94e3-793594015bea"
01-18 13:30:10:969 [ warning nextcloud.sync.networkjob ]:	QNetworkReply::NetworkError(ContentOperationNotPermittedError) "Server replied \"405 Method Not Allowed\" to \"PROPFIND $$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati\"" QVariant(int, 405)
01-18 13:30:10:969 [ info nextcloud.sync.networkjob.lscol ]:	LSCOL of QUrl("$$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati") FINISHED WITH STATUS "ContentOperationNotPermittedError Server replied \"405 Method Not Allowed\" to \"PROPFIND $$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati\""
01-18 13:30:10:969 [ warning nextcloud.sync.discovery ]:	LSCOL job error "Error transferring $$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati - server replied: Method Not Allowed" 405 QNetworkReply::NetworkError(ContentOperationNotPermittedError)
01-18 13:30:10:969 [ warning nextcloud.sync.csync.updater ]:	opendir failed for  - errno 1
01-18 13:30:10:969 [ warning nextcloud.sync.engine ]:	ERROR during  csync_update :  "Permission denied. Error transferring $$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati - server replied: Method Not Allowed"
01-18 13:30:10:970 [ info nextcloud.sync.database ]:	Closing DB "/root/IMPORT/._sync_be711f0f58f2.db"
01-18 13:30:10:970 [ info nextcloud.sync.engine ]:	CSync run took  46 ms
01-18 13:30:10:971 [ info nextcloud.sync.database ]:	Closing DB "/root/IMPORT/._sync_be711f0f58f2.db"

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'passwordsalt' => 'XXX',
  'secret' => 'XXX',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'XXX',
    2 => 'IP',
  ),
  'datadirectory' => '/usr/share/nextcloud/data',
  'overwrite.cli.url' => 'http://localhost',
  'dbtype' => 'mysql',
  'version' => '20.0.5.2',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'XXX',
  'dbpassword' => 'XXX',
  'logtimezone' => 'UTC',
  'installed' => true,
  'instanceid' => 'ocp6cpozfrmk',
  'maintenance' => false,
  'theme' => '',
  'log_type' => 'file',
  'logfile' => 'nextcloud.log',
  'loglevel' => 1,
  'logdateformat' => 'F d, Y H:i:s',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'app_install_overwrite' => 
  array (
    0 => 'calendar',
    1 => 'passman',
    2 => 'ocr',
    3 => 'files_fulltextsearch_tesseract',
  ),
  'updater.release.channel' => 'stable',
  'updater.secret' => 'XXX',
);

where can i find a good giude to use and configure nextcloudCMD? thx

1 Like

did you find a solution ? I am facing the same problem

1 Like

@poisoncloud @wieluk

The links specified in the Nextcloudcmd Documentation assume you are running your Nextcloud on https://server/nextcloud/ but most people run it directly under https://server. Thats why you get redirected to your Dashbord and thats why the command is failing.

 [ info nextcloud.sync.networkjob ]:	Redirecting "GET" QUrl("$$NC_IP_HTTPS$$/nextcloud/ocs/v1.php/cloud/capabilities?format=json") QUrl("$$NC_IP_HTTPS$$/index.php/apps/dashboard/")

So you should use something like this:

root@DOCUMENTS:~# nextcloudcmd --user $$USER$$ --password $$PASSWORD$$ /root/IMPORT $$NC_IP_HTTPS$$/remote.php/webdav/Importati

and not:

root@DOCUMENTS:~# nextcloudcmd --user $$USER$$ --password $$PASSWORD$$ /root/IMPORT $$NC_IP_HTTPS$$/nextcloud/remote.php/webdav/Importati
1 Like