How i turn off Qnap from ssh

Will it work for WOL after you power it off by command "/sbin/poweroff’?

Have you try to use another user account instead of admin to run this command? will it work? thanks.

WOL: Yes, WOL after a poweroff for QNAP NAS.

Poweroff: I just implemented this WOL and poweroff for 2 different QNAP devices, both needed the ‘/sbin/poweroff’ command. This was also confirmed to me by the QNAP service.
As a user I have had a new user created and made an administrator, and added the SSH key to this user as well.
But in my case it only works with the “admin” user and NOT with the newly created user.

edit: QNAP service just confirmed to me that poweroff command is limited to be executed by the admin account only.

1 Like

THANK YOU!!! I was going round and round in circles trying to get it work with an alt administrator account to no avail (I disabled the default admin account for security reasons) but have just tested with the default admin account and it works like a charm!

Hello all,

is there a way to connect with administrator account and NOT with the admin superuser account please? because my admin account is disable for security concern…

i try root, administrator, same : “Fail to connect” when i send the SSH command from HA.

I even activate back the admin superuser and it didnt work : “fail to connect” message in Qnap log

summary of steps required:

ssh into HA

cd config
mkdir ssh
ssh-keygen -b 2048 -t rsa

type a name, such as : nas_qnap

cat nas_qnap

copy the content

login with “admin” account on your QNAP
Using admin account is mandatory, be sure the SSH is enabled in the option of the QNAP.

Select “admin” profile in the top right and and go to access and security → SSH keys. Add a new ssh key and then paste the content you copied before from HA.

go to back to your HA, open the config file and edit it by following the example below:

wake_on_lan:
switch:
  - platform: wake_on_lan
    mac: "FF:FF:FF:FF:FF:FF"
    name: "QNAP"
    host: 192.168.X.X
    turn_off:
        action: shell_command.turn_off_nas
shell_command:
    turn_off_nas: "ssh -i /config/ssh/nas_qnap -o StrictHostKeyChecking=no -q [email protected] poweroff"
1 Like

I followed all the helpfull post, but I’m stuck at the command to power off.

Qnap TS-251+ with QTS 5.2.1.2930 Build 20241025

The ssh key is copied and this part is working.
Both of the mentioned version ‘/sbin/poweroff’ and ‘poweroff’ I have tested.

ssh -i /config/ssh_keys/id_rsa_qnap -o StrictHostKeyChecking=no -q [email protected] ‘poweroff’
ssh -i /config/ssh_keys/id_rsa_qnap -o StrictHostKeyChecking=no -q [email protected] ‘/sbin/poweroff’

Response is:
sh: ‘poweroff’: No such file or directory
sh: ‘/sbin/poweroff’: No such file or directory

Does anyone have simular problems?