Remotely shutdown/restart Windows via Linux on Debian/Ubuntu based Linux

Need samba-common package first, install via apt:

$ sudo apt-get install samba-common

Then use this command to shutdown the computer remotely(replace ip, username and password with your own):

$ net rpc shutdown --ipaddress ip --user username%password

Add -r if you want to restart, not shutdown:

$ net rpc shutdown -r --ipaddress ip --user username%password

After execution, here is the success message:

Shutdown of remote machine succeeded

If receive these messages below means something failed:

Could not connect to server 192.168.1.55
Connection failed: NT_STATUS_IO_TIMEOUT
Connection failed: NT_STATUS_RESOURCE_NAME_NOT_FOUND
Could not initialise pipe winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND

There are many functions provide by net [rpc], like:

net rpc audit Modify global audit settings
net rpc info Show basic info about a domain
net rpc join Join a domain
net rpc oldjoin Join a domain created in server manager
net rpc testjoin Test that a join is valid
net rpc user List/modify users
net rpc password Change a user password
net rpc group List/modify groups
net rpc share List/modify shares
net rpc file List open files
net rpc printer List/modify printers
net rpc changetrustpw Change trust account password
net rpc trustdom Modify domain trusts
net rpc abortshutdown Abort a remote shutdown
net rpc shutdown Shutdown a remote server
net rpc samdump Dump SAM data of remote NT PDC
net rpc vampire Sync a remote NT PDC’s data into local passdb
net rpc getsid Fetch the domain sid into local secrets.tdb
net rpc rights Manage privileges assigned to SID
net rpc service Start/stop/query remote services
net rpc registry Manage registry hives
net rpc shell Open interactive shell on remote server
net rpc trust Manage trusts
net rpc conf Configure a remote samba server

Check man rpc for more details!

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。