Подскажите пожалуйста наиболее простой в реализации способ выключить ПК на Windows 10 используя командную строку Linux… Собственно, сервак на Linux должен по расписанию вырубать ПК =)
Спасибо
-
Вопрос задан
-
3035 просмотров
#!/bin/bash
DOMAIN="roga-i-kopyta.com"
USER="V.Pupkin"
PASS="Pa$$w0rd"
HOST="192.168.77.66"
net rpc shutdown -f -U "$DOMAIN"'\'"$USER"'%'"$PASS" -t 2 -I "$HOST"
Пригласить эксперта
- Поставить на Windows либо OpenSSH либо FreeSSHD
по первому есть некоторые проблемы в установке (с правами на файлы), смотрите доки
PS: небольшой оффтоп: так же Far не работает под OpenSSH, под FreeSSHD работает, но есть mc (Midnight Commander) под Windows, правда ущербный, но для копирования файлов и редактирования текстовых файлов пойдет. - установить telnet сервер в компонентах Windows, по умолчанию он отключен (ибо не секьюрно)
Далее… подключаетесь на Windows PC по ssh, либо telnet пользователем с правами администратора и выполняете командуshutdown -s -f -t 0
или посылаете команду по SSH
ssh administrator@windowspchost shutdown -s -f -t 0
PPS: и… да, пользователь windows скорее всего должен иметь логин из английских букв, чтобы не было проблем с кодировкой при передаче логина (а они скорее всего будут)
-
Показать ещё
Загружается…
09 окт. 2023, в 15:21
1500 руб./за проект
09 окт. 2023, в 15:04
50000 руб./за проект
09 окт. 2023, в 14:50
7000 руб./за проект
Минуточку внимания
There may be more setup to do, especially for Windows Vista, Windows 7 and further windows versions, to allow remote shutdown:
Part A) On the Windows machine:
1) Add a remote shutdown security policy:
-
run
secpol.msc
-
in the program tree, open
Security Settings
>Local Policies
>User rights Assignment
-
Find the entry
Force shutdown from a remote system
-
Edit the entry, add the windows user account that will be used for shutdown (ex: nouknouk)
2) Add registry keys to disable UAC remote restrictions:
-
Run
regedit.exe
as Administrator -
Find
HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System
-
Create a new registry
DWORD(32)
value namedLocalAccountTokenFilterPolicy
and then assign it the value1
3) Start remote registry service:
-
Open
cmd.exe
as Administrator -
Execute the two following commands:
sc config RemoteRegistry start= auto
sc start RemoteRegistry
Part B) On the Linux machine:
1) install the package samba-common
:
It depends on your Linux distribution, but for Debian and derivated (Ubuntu, Linux Mint, …), the apt-get command can be executed like that:
apt-get install samba-common
2) To actually shutdown your Windows machine from the Linux one, run the following command:
net rpc shutdown -f -t 0 -C 'message' -U userName%password -I xxx.yyy.zzz.ttt
Where:
-
-f
means force shutting down all applications (may be mandatory) -
-t 0
is the delay before doing it (0 means ‘right now’). -
-U user%password
is the local user and his password on the windows machine (the one that has been allowed to do remote shutdown in part A). -
-I
is the IP address of the windows machine to shutdown.
If you’ve ever wanted to remotely reboot a Windows box from your Linux machine, the Command-Line Fu web site has you covered with the quick and easy command to use.
In order to actually use this command, you’ll need to make sure that you have the samba-common package installed for Ubuntu, or the corresponding package for your Linux distribution. The simple sudo apt-get install samba-common
command will do it for any Debian-based Linux.
Now you can reboot a machine remotely with the following syntax, making sure to use a username that has administrative privileges on the Windows box:
net rpc shutdown -I IPADDRESS -U USERNAME%PASSWORD
If you omit the password section, you’ll be prompted on the command line for the password—which might be more secure if you are worried about somebody looking through your terminal history. You can add the -f
parameter to force a shutdown, which might be necessary to make sure the remote machine actually shuts down.
Readers should note that a number of factors may influence whether this technique actually works—if the machine has a desktop firewall installed or the file sharing services are disabled it probably won’t work, but it’s still a very helpful technique that might come in handy.
For more, learn how you can shutdown Windows with a text message, use the shutdown.exe GUI to turn Windows off, or even shutdown, restart, or sleep your Vista PC in a few keystrokes.
Shutdown a Windows machine from Linux [Command-Line Fu]
I have a system comprised of, let’s say 10 Windows 7 Professional workstations, joined to a domain.
As part of an «emergency» system shutdown procedure, I’d like a mechanism of triggering a remote shutdown, from a Linux controller (which is in turn, a service orchestration tool). The word «emergency» is in quotes because it’s not really an emergency, but still need a mechanism other than simply telling the users to turn the workstations off.
So, I’ve looked at psexec
, which is almost ideal, except only seems triggerable from another windows machine. .. I suppose it’s not impossible to have a windows server trigger the workstation shutdown procedure, but that’s not ideal.
I gather one option is to install Cygwin, and OpenSSH, but frankly, that seems bulky.
What I’d like, ideally.. Is a program that runs as a service, with local (or domain) Administrator privileges, listening on a port, for a SSL-encrypted, RESTful API call like, http://workstation:8888/admin/shutdown?key=secretsharedkey
.
Do I need to write something in C#.net, or is there a tool out there for cross-platform triggering of a shutdown of a windows workstation?
How do you remotely shutdown an XP host from a linux machine? I know that you can use
shutdown /s /f /m \IP_GOES_HERE
From windows, but how would you do that from linux? (wine does not port the shutdown
command)
asked Feb 10, 2010 at 22:32
bricebrice
2,3761 gold badge23 silver badges24 bronze badges
Does the psshutdown tool from SysInternals (nor part of MS) work under Wine? Probably not, but might be worth a try.
Failing that you could install cygwin’s OpenSSH port (or some other SSH server service) and use that to login and call Windows’ own local shutdown command — this would be a one line command/script.
answered Feb 10, 2010 at 22:43
David SpillettDavid Spillett
23.4k2 gold badges49 silver badges69 bronze badges
2
psshutdown doesn’t work from wine for some reason.
however,
net rpc shutdown -I xxx.xxx.xxx.xxx -U username%password
works if all the proper steps have been taken
answered Feb 11, 2010 at 0:16
bricebrice
2,3761 gold badge23 silver badges24 bronze badges
I used the psshutdown, but had a different method.
I had Outlook open on the machine 24/7 and if it received an email from my email account only, with a random set of words in it, the rule would run psshutdown
you could try this
you could even use this mthod to shiut the computer off from a text message!
answered Feb 11, 2010 at 0:36
qwertyKidqwertyKid
2421 silver badge3 bronze badges
If you create a shortcut link to this from the windows machine you can simply do it that way.
Put this in the Target text box:
C:\WINDOWS\system32\shutdown.exe -s -f -c «Shutdown!» -t 10
Put this in the Start in text box:
C:\Windows\System32
answered Feb 11, 2010 at 0:21
DanielDaniel
1,4356 gold badges24 silver badges41 bronze badges
You must log in to answer this question.
Not the answer you’re looking for? Browse other questions tagged
.
Not the answer you’re looking for? Browse other questions tagged
.