nextcloudcmd mangling address

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.4
  • Operating system and version (e.g., Ubuntu 24.04):
    • `Debian 11 (server)
    • Debian 12 (client)
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2.4.62
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • none
  • PHP version (e.g, 8.3):
    • 8.3.15
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • when I updated the client script to use nextcloudcmd instead of owncloudcmd
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Archive from nextcloud
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • Negative

Summary of the issue you are facing:

I am encountering an issue using nextcloudcmd to automate upload of a file to the server. According to the ‘Credential Handling’ section in the Advanced Usage section of the documentation,

"nextcloudcmd requires the user to specify the username and password using the standard URL pattern, e.g.,

$ nextcloudcmd /home/user/my_sync_folder https://carla:secret@server/nextcloud

(emphasis mine)

When I attempt to upload, I get a host not found error. The URL shown is not the URL I entered on the command line. Note that in the below example, I am using fake information, as this URL is an internal URL.

I enter:

nextcloudcmd --non-interactive --trust /var/opt/LincolnRadioJournal/ https://'user':'P@ssw0rd!'@123.456.789.101/LRJ

In the output from the command, I see the following as the first line:

01-05 12:03:27:627 [ info nextcloud.sync.accessmanager ]:	2 "" "http://https//user:P@ssw0rd!@123.456.789.101/LRJ/ocs/v1.php/cloud/capabilities?format=json" has X-Request-ID "5688e5f0-9e49-4256-bc4c-c3a9fcf3329b"

If I drop the ‘https://’ from the URL, then the connection shows just the user:P@ssw0rd!@123.456.789.101… as the URL - no protocol, and the connection fails the same way - host not found. The full output from the command looks like this:

01-05 12:03:27:627 [ info nextcloud.sync.accessmanager ]:	2 "" "http://https//user:P@ssw0rd!@123.456.789.101/LRJ/ocs/v1.php/cloud/capabilities?format=json" has X-Request-ID "5688e5f0-9e49-4256-bc4c-c3a9fcf3329b"
01-05 12:03:27:629 [ info nextcloud.sync.networkjob ]:	OCC::JsonApiJob created for "http://https//user:P@ssw0rd!@123.456.789.101/LRJ" + "ocs/v1.php/cloud/capabilities" ""
01-05 12:03:27:692 [ warning nextcloud.sync.networkjob ]:	QNetworkReply::HostNotFoundError "Host https not found" QVariant(Invalid)
01-05 12:03:27:692 [ info nextcloud.sync.networkjob.jsonapi ]:	JsonApiJob of QUrl("http://https//user:P@ssw0rd!@123.456.789.101/LRJ/ocs/v1.php/cloud/capabilities?format=json") FINISHED WITH STATUS "HostNotFoundError Host https not found"
01-05 12:03:27:692 [ warning nextcloud.sync.networkjob.jsonapi ]:	Network error:  "ocs/v1.php/cloud/capabilities" "Host https not found" QVariant(Invalid)
01-05 12:03:27:692 [ debug default ]	[ main(int, char**)::<lambda ]:	Server capabilities QJsonObject()

If I use the --user and --password parameters instead, the URL is not mangled, but it also fails to connect with ‘Host requires authentication’:

wmssnm01$ nextcloudcmd --non-interactive --trust --user 'user' --password 'P@ssw0rd' /var/opt/LincolnRadioJournal/ https://123.456.789.101/LRJ
01-05 12:12:29:573 [ info nextcloud.sync.accessmanager ]:	2 "" "https://123.456.789.101/LRJ/ocs/v1.php/cloud/capabilities?format=json" has X-Request-ID "347a52f8-8525-4847-9e29-fa6d5b6e5446"
01-05 12:12:29:573 [ info nextcloud.sync.networkjob ]:	OCC::JsonApiJob created for "https://123.456.789.101/LRJ" + "ocs/v1.php/cloud/capabilities" ""
01-05 12:12:29:581 [ info nextcloud.sync.account ]:	"SSL-Errors happened for url  \"https://123.456.789.101/LRJ/ocs/v1.php/cloud/capabilities?format=json\" \tError in  QSslCertificate(\"3\", \"04:ed:cf:5e:c3:a3:26:91:85:55:81:7c:a5:83:c3:a9:db:83\", \"JDU9+3FpsCj9pkEv5jltDQ==\", \"E6\", \"ingest.wmssfm.com\", QMap((1, \"ingest.wmssfm.com\")), QDateTime(2024-12-13 01:32:22.000 UTC Qt::UTC), QDateTime(2025-03-13 01:32:21.000 UTC Qt::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 " Certs are known and trusted! This is not an actual error.
01-05 12:12:30:732 [ warning nextcloud.sync.networkjob ]:	QNetworkReply::AuthenticationRequiredError "Host requires authentication" QVariant(int, 401)
01-05 12:12:30:732 [ info nextcloud.sync.networkjob.jsonapi ]:	JsonApiJob of QUrl("https://123.456.789.101/LRJ/ocs/v1.php/cloud/capabilities?format=json") FINISHED WITH STATUS "AuthenticationRequiredError Host requires authentication"
01-05 12:12:30:732 [ warning nextcloud.sync.networkjob.jsonapi ]:	Network error:  "ocs/v1.php/cloud/capabilities" "Host requires authentication" QVariant(int, 401)
01-05 12:12:30:732 [ debug default ]	[ main(int, char**)::<lambda ]:	Server capabilities QJsonObject()
Error connecting to server
wmssnm01$

Not the SSL cert failure is expected, as the cert is for the public FQDN of the server, not the internal address - and I am having an issue with splitting the DNS at the moment, but unrelated to this (other clients connect just fine internally).

Steps to replicate it (hint: details matter!):

  1. run the nextcloudcmd shown in the issue description above.

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

{"reqId":"Z3q9xLxmPtG1SpDLmTMylAAAAAc","level":2,"time":"2025-01-05T17:13:41+00:00","remoteAddr":"192.168.92.141","user":"--","app":"core","method":"GET","url":"/LRJ/ocs/v1.php/cloud/capabilities?format=json","message":"Login failed: 'LRJ' (Remote IP: '192.168.92.141')","userAgent":"Mozilla/5.0 (Linux) mirall/3.1.1-2+deb11u1 (Nextcloud)","version":"30.0.4.1","data":{"app":"core"},"id":"677ac4f148b1f"}
{"reqId":"Z3q9mxK7EoK-utbZ20U0gwAAAAA","level":2,"time":"2025-01-05T17:13:00+00:00","remoteAddr":"192.168.92.141","user":"--","app":"core","method":"GET","url":"/LRJ/ocs/v1.php/cloud/capabilities?format=json","message":"Login failed: 'LRJ' (Remote IP: '192.168.92.141')","userAgent":"Mozilla/5.0 (Linux) mirall/3.1.1-2+deb11u1 (Nextcloud)","version":"30.0.4.1","data":{"app":"core"},"id":"677ac4f148b27"}
{"reqId":"Z3q9xLxmPtG1SpDLmTMylAAAAAc","level":2,"time":"2025-01-05T17:13:41+00:00","remoteAddr":"192.168.92.141","user":"--","app":"core","method":"GET","url":"/LRJ/ocs/v1.php/cloud/capabilities?format=json","message":"Login failed: 'LRJ' (Remote IP: '192.168.92.141')","userAgent":"Mozilla/5.0 (Linux) mirall/3.1.1-2+deb11u1 (Nextcloud)","version":"30.0.4.1","data":{"app":"core"},"id":"677ac4e754c15"}
{"reqId":"Z3q9xLxmPtG1SpDLmTMylAAAAAc","level":2,"time":"2025-01-05T17:13:41+00:00","remoteAddr":"192.168.92.141","user":"--","app":"core","method":"GET","url":"/LRJ/ocs/v1.php/cloud/capabilities?format=json","message":"Login failed: 'LRJ' (Remote IP: '192.168.92.141')","userAgent":"Mozilla/5.0 (Linux) mirall/3.1.1-2+deb11u1 (Nextcloud)","version":"30.0.4.1","data":{"app":"core"},"id":"677ac4f148b1f"}

Web Browser

If the problem is related to the Web interface, open your browser inspector Console and Network tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

[Not Applicable]

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

ingest.wmssfm.com:443 123.456.789.101 - LincolnRadio [05/Jan/2025:11:27:07 -0500] "GET /remote.php/dav/files/LincolnRadio/LRJ/ocs/v1.php/cloud/capabilities?format=json HTTP/1.1" 401 4863 "-" "Mozilla/5.0 (Linux) mirall/3.1.1-2+deb11u1 (Nextcloud)"
ingest.wmssfm.com:443 123.456.789.101 - LRJ [05/Jan/2025:12:12:59 -0500] "GET /LRJ/ocs/v1.php/cloud/capabilities?format=json HTTP/1.1" 401 4282 "-" "Mozilla/5.0 (Linux) mirall/3.1.1-2+deb11u1 (Nextcloud)"
ingest.wmssfm.com:443 123.456.789.101 - LRJ [05/Jan/2025:12:13:40 -0500] "GET /LRJ/ocs/v1.php/cloud/capabilities?format=json HTTP/1.1" 401 4280 "-" "Mozilla/5.0 (Linux) mirall/3.1.1-2+deb11u1 (Nextcloud)"

(These are the only entries in the Apache ‘other_vhosts_access.log’ that are for this client. The access.log file does not contain anything for this host/user, nor does error.log file.)

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "192.168.92.29",
            "nextcloud.wmssfm.com",
            "ingest.wmssfm.com",
            "108.11.218.172"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "enable-previews": false,
        "dbtype": "mysql",
        "version": "30.0.4.1",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "maintenance_window_start": 1,
        "maintenance": false,
        "default_phone_region": "US",
        "knowledgebaseenabled": true,
        "session_lifetime": 86400,
        "session_keepalive": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "timeout": 0
        },
        "memcache.local": "\\OC\\Memcache\\APCu",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_sendmailmode": "smtp",
        "app_install_overwrite": [
            "admin_notifications"
        ]
    }
}

Thanks in advance for any assistance provided!

I can’t reproduce this problem, but I do notice you seem to be running an ancient of the client. Debian 12 has at least 3.7.3 (which is still old-ish, but at least not 3.1.1 old).

Thanks.

It looks like I have the client/server backwards in my listing. The client is running on Debian 11, the server on Debian 12. Apologies for the error.

Looking at the Debian packages, it looks like 3.1.1-2+deb11u1 is the Bullseye version and 3.7.3-1+deb12u1 the Bookworm version.

I have been planning to take this box to Bookworm (wmssnm01 - the client), I will go ahead and do that and see if the newer client makes a difference.

While I have not had a resolution to the problem as presented, I have discovered a couple of things.

If I use the -u ‘User’ and -p ‘Password’ parameters, the connection still fails, this time with a 401 error. The password had a format similar to:

!Abcdef@123*

Nextcloudcmd apparently did not like something there. I changed to password to something simpler, such as:

Abcdef123*

Password rules require at least one special character.

I no longer get a 401 error, but I still get a connection failure. This time, a 404. More URL shenanigans. My command line looks like this:

nextcloudcmd --trust --non-interactive -u 'Username' -p 'Password123*' /var/opt/LocalDirectory/ https://server.domain.tld/Username/

I get a 404 error when the client attempts to connect to:

https://server.domain.tld/Username/status.php

then attempts

https://server.domain.tld/Username/nextcloud/status.php

The latter should fail - as nextcloud is not part of the server path. It is the only thing running on this server and is set up as the webserver root in the site configuration file.

The full error I receive (I left the HTML part at the end out):

me@pc# nextcloudcmd --trust --non-interactive -u 'Username' -p 'Password123*' /var/opt/LocalDirectory/ https://server.domain.tld/Username/
01-22 23:21:49:008 [ info nextcloud.sync.accessmanager ]:	2 "" "https://server.domain.tld/Username/status.php" has X-Request-ID "ccfa1218-36f7-4211-84df-0d284c9d8fc2"
01-22 23:21:49:009 [ info nextcloud.sync.networkjob ]:	OCC::CheckServerJob created for "https://server.domain.tld/Username" + "status.php" ""
01-22 23:21:56:377 [ warning nextcloud.sync.networkjob ]:	QNetworkReply::ContentNotFoundError "Server replied \"404 Not Found\" to \"GET https://server.domain.tld/Username/status.php\"" QVariant(int, 404)
01-22 23:21:56:377 [ info nextcloud.sync.accessmanager ]:	2 "" "https://server.domain.tld/Username/nextcloud/status.php" has X-Request-ID "651205ae-4449-4a59-a99c-579f1baf0763"
01-22 23:21:56:379 [ info nextcloud.sync.networkjob ]:	OCC::CheckServerJob created for "https://server.domain.tld/Username" + "nextcloud/status.php" ""
01-22 23:21:56:379 [ info nextcloud.sync.networkjob.checkserver ]:	Retrying with QUrl("https://server.domain.tld/Username/nextcloud/status.php")
01-22 23:21:58:011 [ warning nextcloud.sync.networkjob ]:	QNetworkReply::ContentNotFoundError "Server replied \"404 Not Found\" to \"GET https://server.domain.tld/Username/nextcloud/status.php\"" QVariant(int, 404)
01-22 23:21:58:011 [ warning nextcloud.sync.networkjob.checkserver ]:	error: status.php replied  404 "<!DOCTYPE html>\n<html class=\"ng-csp\" data-placeholder-focus=\"false\" lang=\"
<multiple lines of HTML removed>
dden\" id=\"initial-state-firstrunwizard-android\" value=\"Imh0dHBzOlwvXC9wbGF5Lmdvb2d"
Error connecting to server for status
me@pc#

I have to be missing something somewhere. I need to put the file into a specific directory on the server (Username in the example), because this directory is synchronized by another user with another client on another machine to automagically retrieve and process the file placed in that directory.

Am I missing something somewhere in the syntax? I pulled what I am using from the documentation on nextcloudcmd.

This is using client version 3.7.3git from the Debian 12 repositories. I am running the command on a different machine that has both a GUI and is running Debian 12. The web page behaves just fine with a browser (Firefox ESR)