Mender-cli cp 405 Not Allowed

Hi There,

I’m trying to use mender-cli to copy a file from my local workstation to a Mender device.

The device is connected. I am able to connect to the terminal and port forward using mender-cli but the cp command gives me the error below.

mender-cli cp --server $MENDER_SERVER --token-value $MENDER_PAT upsize.sh <DEVICE_ID>:/home/test/
Configuration file not found. Continuing.
Error: Received unexpected response code: 405
FAILURE: Error: <html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx</center>
</body>
</html>

I was thinking it could be due to permissions so i configured /etc/mender/mender-connect.conf to use root user but still i get the 405 error.

mender-client is version 3.5.0
We are using self hosted mender version 3.4.0

Hello @dunning.simon

thank you for using Mender. it is nice to meet you.
could you please do four things for me:

  • restart mender-connect on a device
  • share the mender-connect config file with me
  • do the same command but trying the terminal:
mender-cli terminal --server "$MENDER_SERVER" --token-value "$MENDER_PAT" <DEVICE_ID>
  • give me the output of ps axuw | grep mender from the device

best regards,
peter

hi @peter , I’m also seeing this same issue with mender-cli using the cp command. I’m able to connect via the terminal command, port-forward etc, but cp throws a 405 and the request doesn’t seem to be hitting the machine’s client at all.

> mender-cli cp ./scripts/test/moadmin-start.original 2d204bca-518c-4a74-9ce0-b5e602890de0:/home/moadmin/testing_file -v

results in

Using configuration file: /Users/atartanian/Development/moutfitters/mo_local_kiosk/.mender-clirc
VERBOSE verbose output is ON
VERBOSE sending request: 
GET /api/management/v1/deviceconnect/devices/2d204bca-518c-4a74-9ce0-b5e602890de0 HTTP/1.1
Host: hosted.mender.io
Authorization: Bearer <redacted>

VERBOSE Uploading the file to /home/moadmin/testing_file
VERBOSE sending request: 
PUT //api/management/v1/deviceconnect/devices/2d204bca-518c-4a74-9ce0-b5e602890de0/upload HTTP/1.1
Host: hosted.mender.io
Authorization: Bearer <redacted>
Content-Type: multipart/form-data; boundary=d2a00a6d8fe7ea03f73d3a0cb3e5e1e3fe716b58bb7f50e8f594cd2f0ae5

Error: Received unexpected response code: 405
FAILURE: Error: <html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx</center>
</body>
</html>

mender-connect config looks like this:

{
    "ShellCommand": "/bin/sh",
    "User": "root"
}

and here’s the process showing that mender-connect is running (our devices are running a minimal version of ps so I can’t use the axuw options):

root@raspberrypi4-64:/etc/mender# ps | grep mender
  632 root     1652m S    /usr/bin/mender --no-syslog daemon
  633 root     1565m S    /usr/bin/mender-connect daemon
62469 root      2960 S    grep mender

any help would be much appreciated!

EDIT: I’ve also found that downloading files doesn’t work either, but throws a 404 File Not Found on Device

> mender-cli cp 2d204bca-518c-4a74-9ce0-b5e602890de0:/home/moadmin/moadmin-start ./isItWorking -v


Using configuration file: /Users/atartanian/Development/moutfitters/mo_local_kiosk/.mender-clirc
VERBOSE verbose output is ON
VERBOSE sending request: 
GET /api/management/v1/deviceconnect/devices/2d204bca-518c-4a74-9ce0-b5e602890de0 HTTP/1.1
Host: hosted.mender.io
Authorization: Bearer <redacted>

VERBOSE sending request: 
GET //api/management/v1/deviceconnect/devices/2d204bca-518c-4a74-9ce0-b5e602890de0/download?path=%2Fhome%2Fmoadmin%2Fmoadmin-start HTTP/1.1
Host: hosted.mender.io
Authorization: Bearer <redacted>

VERBOSE Response: 
HTTP/1.1 404 Not Found
Content-Length: 54
Connection: keep-alive
Content-Type: application/json
Date: Fri, 31 May 2024 19:20:45 GMT
Referrer-Policy: no-referrer
Server: nginx
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block

{"error": {"status_code": 404,"message": "Not Found"}}
File not found on the device

FAILURE: Error: {"error": {"status_code": 404,"message": "Not Found"}}

Hello @atartanianMO ,

thank you for using Mender.
this seems a bit strange, I need:

  1. your exact Mender Client, and Mender Connect versions.
  2. logs from mender-connect: journalctl -u mender-connect > /tmp/mc.log; and the same for mender-client
  3. output of stat /home/moadmin/moadmin-start on the device.

sorry about lots of requests :slight_smile:

best regards,
peter