My Cloud OS 5 - Shutdown via SSH/Rest

Hi !

I boot a WD EX2 Ultra using WOL.

On My Cloud OS 3 i shut down the device via REST command (http://localhost/api/@REST_API_VERSION/rest/shutdown)

Was the REST API removed in OS 5 ?

Under OS 5 i found script /opt/wd/sbin/ - is this the correct script to shutdown (hibernate) the device (works fine using option -s 0) via ssh - or should i use ?

Which script exactly is executed if i click on “Hibernate” on UI ?

br, uberl


Have found a more correct approach via default dashboard using curl:

  1. login to dashboard
    sample admin password = ‘demo’
    base64_encoded_password(‘demo’) = ‘ZGVtbw==’
    curl -sSL -o /dev/null -c /home/me/cookie.dat --header 'Content-Type: application/json' --request POST --data '{"username":"admin","password":"ZGVtbw=="}'

  2. activate hibernate
    curl -sSL -o /dev/null -b /home/me/cookie.dat

  3. logout
    curl -sSL -o /dev/null -b /home/me/cookie.dat --request DELETE


Thank you for supplying a new approach for version OS 5, but it doesn’ really work for me.

First, using:
/opt/wd/sbin/ -s 0
with plink (puTTy) like:
plink -ssh -batch sshd@192.168.0.XXX -pw XXXXXX /opt/wd/sbin/ -s 0
doesn’t work for me - I can’t WOL the system afterwards…

Second, in
curl -sSL -o /dev/null -c /home/me/cookie.dat --header 'Content-Type:application/json' --request POST --data '{"username":"admin","password":"XXXXX"}' http://192.168.0.XXX/nas/v1/auth
I get the error

curl: (23) Failed writing body (0 != 31)

can you assist or share your solution? - I believe it is also a batch file…
Thank you very much!

use correct/existing path for saving </home/me/>cookie.dat

thank you!
I found this out myself, but I am still struggling with the rest. should it be like this?:
curl -sSL -o dev.txt -c cookie.txt --header 'Content-Type:application/json' --request POST --data '{"username":"admin","password":"XXX"}' http://192.168.0.XXX/nas/v1/auth
in the output file (dev.txt) i get the output:
and also no cookie file (cookie.txt) is created.
any idea?

if using --ssl instead of -sSL i get the following info in command prompt:

but still no cookie.txt and also {"error":"0","eula_status":"1"} in dev.txt
edit: now I understand that -sSL is something completly different from --ssl :stuck_out_tongue_winking_eye:

did you base64 encoded the password ?

Hi uberl,

thank you. I actually forgot to do this, but even with the encoded password it doesn’t work either.
Any further suggestions? :slight_smile:
current file looks like:
curl -sSL -o dev.txt -c C:\cookie.dat --header 'Content-Type:application/json' --request POST --data '{"username":"admin","password":"MGI1dDV[...]EX2FkbWlu"}' http://192.168.0.XXX/nas/v1/auth
curl -sSL -b C:\cookie.dat http://192.168.0.XXX/cgi-bin/system_mgr.cgi?cmd=cgi_shutdown

on windows try double quote

curl -sSL -o dev.txt -c C:\cookie.dat --header "Content-Type:application/json" --request POST --data "{\"username\":\"admin\",\"password\":\"MGI1dDV[...]EX2FkbWlu\"}" http://192.168.0.XXX/nas/v1/auth

Thank you! It works :slight_smile:
I actually had a similar thing to program at work with curl: triggering a flow (microsoft flow) with a HTTP POST, which worked after I changed the quotes as I needed here…
I still think that somethin with using different WOL sources (and ports (7/9)) messed up the system.
Anyhow, it works! hopefully this post is usefull for others as well!

I thought I share my script, which is far away from being optimised, but all necessary aspects should be in it and therefore might inspire some others for creating their own backup batch.

@echo off
choice /t 60 /d n /m “do you like to shutdown after backup?”
if errorlevel 1 set shutdown=true
if errorlevel 2 set shutdown=false
REM start NAS via WOL and wait till it is available
wolcmd […MAC…] […IP…] […SUBNET…] 9
REM […MAC…] = MAC address, etc. + download
for /L %%N IN (1, 1, 30) DO (
timeout /t 10
echo waiting ^(%%N^) for NAS to be available…
if exist “\\MyCloudEX2Ultra\[…]\BACKUP-Info.txt” (
REM choose any file as an indicator (ping doesn’t work as device is still booting while it can be pinged)
goto available
goto fail
TASKKILL /F /IM “thunderbird.exe”
robocopy “C:\Users[…]” “\\MyCloudEX2Ultra\[…]” /xf *._ /mir /z /r:1 /w:0 /fft /xd C:\[…]
REM xf=exclude file, xd=exclude dir, etc.
goto success
echo succesfully backuped at: %date% >> “\\MyCloudEX2Ultra\[…]\BACKUP-Info.txt”
REM now shutdown NAS again
curl -sSL -c cookie.dat --header “Content-Type:application/json” --request POST --data “{\“username\”:\“admin\”,\“password\”:\”[…pass64…]\"}" http://[…IP…]/nas/v1/auth
REM […pass64…] =[...pass...]; […IP…] = like 192.168.X.Y
curl -b cookie.dat http://[…IP…]/cgi-bin/system_mgr.cgi?cmd=cgi_shutdown
REM […IP…] = like 192.168.X.Y
del cookie.dat
echo º User º
echo º backuped! º
goto end
echo failed to reach NAS!
timeout /t 20
goto end
if %shutdown%==true (
echo shutting down PC after timeout ^(with 120s delay to wait for NAS^)!
timeout /t 30
shutdown -s -t 120
pause > nul