Shut down DNS-323 remotely

1,004 views
Skip to first unread message

Lukas Trtik

unread,
Jan 21, 2014, 7:35:09 AM1/21/14
to al...@googlegroups.com
Hello there!

First of all - I am a linux noob:-)

Can I have a question - how do I shut down the DNS-323 (with ALT-F firmware - thank fo that by the way! Way better than the original D-link firmware!) remotely using a Windows script and NOT using the root access? I am for example running backups over night and when completed I want the NAS to shut down automatically.
Currently I am calling /sbin/poweroff using PuTTY:

plink -l root -pw MYPASSWORD //SERVERNAME -m "nas_shutdown.txt"

where nas_shutdown.txt file contains the /sbin/poweroff command.

This works but obviously the root password needs to be stored in the command. What I would ideally like to have is a "shutdown" user who has permission to perform the power off command only but does not have the root access.

Step-by-step instructions would be really appreciated! I know how to connecto to the NAS via ssh but that is basically it...

Thanks!

João Cardoso

unread,
Jan 21, 2014, 9:59:53 AM1/21/14
to al...@googlegroups.com


On Tuesday, January 21, 2014 12:35:09 PM UTC, Lukas Trtik wrote:
Hello there!

First of all - I am a linux noob:-)

Can I have a question - how do I shut down the DNS-323 (with ALT-F firmware - thank fo that by the way! Way better than the original D-link firmware!) remotely using a Windows script and NOT using the root access? I am for example running backups over night and when completed I want the NAS to shut down automatically.

I'm not seeing a way of doing that. Perhaps a cron job?
 
Currently I am calling /sbin/poweroff using PuTTY:

plink -l root -pw MYPASSWORD //SERVERNAME -m "nas_shutdown.txt"

where nas_shutdown.txt file contains the /sbin/poweroff command.

This works but obviously the root password needs to be stored in the command. What I would ideally like to have is a "shutdown" user who has permission to perform the power off command only but does not have the root access.
 
Then you need the 'sudo' Alt-F package, and authorize specific users to run specific programs:

DESCRIPTION
       sudo allows a permitted user to execute a command as the superuser or another user, as
       specified by the security policy.  The real and effective uid and gid are set to match
       those of the target user, as specified in the password database, and the group vector is
       initialized based on the group database (unless the -P option was specified).


Step-by-step instructions would be really appreciated!

I'm sure you will find 'sudo' tutorials out there.

Lukas Trtik

unread,
Jan 21, 2014, 11:29:46 AM1/21/14
to al...@googlegroups.com
Thank you! Will give it a try when I have more time explore the sudo package.

Dne úterý, 21. ledna 2014 15:59:53 UTC+1 João Cardoso napsal(a):

Lukas Trtik

unread,
Jan 21, 2014, 1:55:09 PM1/21/14
to al...@googlegroups.com
Ok, it was raining outside so got some time to test it.
What worked for me:
1) installed Alt-F sudo package
2) created an user called 'shutdown' in Alt-F administration directly (for me - easier than looking for a Linux command)
3) connected via ssh and used visudo to add this: shutdown ALL=NOPASSWD:/sbin/poweroff
4) calling it from Windows using PuTTY: plink.exe -l shutdown -pw PASSWORD SERVERNAME -m nas_shutdown.txt
where nas_shutdown.txt contains: sudo /sbin/poweroff

Not sure whether this is the ideal way but at least I am not sharing the root password within the command anymore. Only fake "shutdown" user's password.



Dne úterý, 21. ledna 2014 17:29:46 UTC+1 Lukas Trtik napsal(a):

Rolf Larsson

unread,
Jan 23, 2014, 10:08:44 AM1/23/14
to al...@googlegroups.com
That'll work, but forces you to store the password in clear text on your windows machine. Scary :-)

If I needed to shut it down remotely, I'd probably have a cron job that every five minutes checked a shared disk (ideally part of the ramdisk to avoid having disks spin up if not required) for a specific file, remove it, then shutdown. Then have the windows script create the file when the backup is done.

Ie similar what the fun_plugin does on startup, but every five minutes or so.

Lukas Trtik

unread,
Jan 23, 2014, 1:31:57 PM1/23/14
to al...@googlegroups.com
Thank you for sharing the idea! I will give it a try when I have some time to get back to this.

Dne čtvrtek, 23. ledna 2014 16:08:44 UTC+1 Rolf Larsson napsal(a):
Reply all
Reply to author
Forward
0 new messages