How to Shutdown Terramaster NAS with SSH keypair and shell_command

Finally the solution was brought by @FriedCheese and @blackfede. Thanks, you made this a great day.

To summarize:

  1. Install and activate ssh on both HA and NAS.

  2. Access HA cli and generate keys with

ssh-keygen

don’t set passphrase and when prompted for file path:

  1. Type: /config/.ssh/id_rsa.pub

  2. Copy the generated keys to NAS using:
    ssh-copy-id -i /config/.ssh/id_rsa.pub user@NAS_IP using your credentials.

  3. Run:
    chmod 600 /config/.ssh/id_rsa’

  4. Create a shell_command entry in config.yaml:

shell_command:
 shutdown_nas: ssh -i /config/.ssh/id_rsa -o 'StrictHostKeyChecking=no' -p 9222 user@NAS_IP /sbin/shutdown

using your credentials.

  1. Restart HA

Now you should be able to call a service called: shutdown_nas

This way, I got rid of the need for a smart UPS.

Please correct me if I badly reported something.
If you encounter an issue, since I mistook almost everything could be mistaken, you’ll likely find the brief solution among replies, so take time to and care of reading.

3 Likes