Turning freenas server OFF from a Raspberry Pi.
On the pi server:
# copy the pi key to the freenas server
ssh-copy-id -i ~/.ssh/id_rsa.pub root@freenas
On the pi server:
# ssh into the nas server from the pi
ssh root@freenas
Now logged into the freenas server:
# edit the sudoers file
visudo
# go to the end, i to insert, add:
root ALL = (ALL) NOPASSWD: /sbin/shutdown -h now
# save and exit ( escape : w q )
Exit the freenas box:
exit
Back on the pi, tell the freenas server to shut down
ssh 'root@freenas' "shutdown -h now"
The box should shut down.