Down them all linux

How can I shutdown all PCs(Linux) with a python script via a Linux terminal (all with ssh enabled and same username and password)

I would like to run a python script that shuts down all PCs on my network. They all are Linux machines with SSH enabled and the same username and password. How can I go about doing this?

3 Answers 3

In my opinion, is better to use a bash script for that, since you can input commands through the ssh command on the machines.

for exemple, a line in bash to execute the command for shutting down a PC through ssh will be:

ssh user1@server1 "sudo shutdown -h now" 

If you still want to do it in Python, Try using the subprocess Module or the os Module to execute shell commands.

First at all, it is much better to use public key authentication for this than store your password somewhere (https://serverpilot.io/docs/how-to-use-ssh-public-key-authentication/).

Then you simply have to call shutdown command through ssh.

import os os.system("ssh user@host 'shutdown now'") 

Obviously your user in your remote system must have privileges to shut down the computer.

Another option is to use Ansible (written in Python, with Python modules), with which you can manage remote servers (almost all OS-es).

Here are some examples of how the Ansible code looks like for multiple reboot scenarios (e.g. test.yml ):

- name: Unconditionally reboot the machine with all defaults reboot: - name: Reboot a slow machine that might have lots of updates to apply reboot: reboot_timeout: 3600 - name: Reboot a machine with shutdown command in unusual place reboot: search_paths: - '/lib/molly-guard' - name: Reboot machine using a custom reboot command reboot: reboot_command: launchctl reboot userspace boot_time_command: uptime | cut -d ' ' -f 5 

Ansible needs to be installed only on your computer (desktop/laptop/server) that will control all other nodes. There is almost no restriction on the OS-es or distros that you can control (this includes Linux, UNIX, Windows etc). The ssh connection needs to be configured (the user and password). Your code will not have to hardcode the list of nodes, username or password, it will be only a configuration.

This setup will probably be the easiest to manage multiple nodes at scale, and can provide capability add additional node management functionality.

To run ansible from Python, Ansible provides the ansible-runner Python package (PyPI, GitHub), which can be used for this.

import ansible_runner r = ansible_runner.run(private_data_dir='/tmp/demo', playbook='test.yml') print("<>: <>".format(r.status, r.rc)) # successful: 0 for each_host_event in r.events: print(each_host_event['event']) print("Final status:") print(r.stats) 

Источник

Free, fast, clean.—> Why just one, when you can DownThemAll?

DownThemAll is a powerful yet easy-to-use extension that adds new advanced download capabilities to your browser.
DownThemAll lets you download all the links or images on a website and much more: you can refine your downloads by fully customizable filters to get only what you really want.
DownThemAll is all you can desire from a download manager: it allows you to queue, pause and resume downloads at any time and is fully integrated in your favorite browser!

Читайте также:  Cisco log to linux

Get it!

News

DownThemAll! 4.4 June 20, 2022

I made a new release today. It was already approved by mozilla for Firefox, and hopefully will be approved soon for Chrome and Edge by Google and Microsoft respectively, as well.

This release fixes some issues, updated translations, and added a *pagetitle* renaming tag.

I also noticed that my Opera account just went “missing” a while back. I will have to investigate what happened there when I have some time. For the time being, Opera users can install the extension from the Chrome Web Store, I think.

Thanks again to anybody who contributed, be it people donating some money, reporting bugs, making pull requests, or translating the add-on.
Your support is appreciated!

Thanks to Scott DeVaney, who first reached out to me, and “zephyr” from the mozilla Add-ons Editors team and maybe others, who reviewed the extension, DownThemAll! is now listed as a Recommended Firefox extension.

The old DownThemAll! (up to version 3.0) was a long term recommended add-on, too, and I am happy that the WebExtension now is as well.

Recommended means that the mozilla team did a thorough review of DownThemAll!, both in code and basic functionality, and found no issues that would put users at risk, and that the extension does not contain any nasty surprises like undisclosed user tracking either (DownThemAll! does not include any tracking, of course, but now you got it confirmed by mozilla).

It also means that future updates will be thoroughly reviewed by mozilla as well before they get published.

Existing users do not have to do anything, as updates are automatic. New users on Firefox will now see the Recommended badge on the Add-on listing page.

And every user gets to see this when opening the Add-ons page in their Firefox:

Источник

DownThemAll! от Nils Maier

Quickly select links using advanced filters, automatically name files and folders with highly configurable masksWatch your download queue progress according to your global and per-domain limits. Quickly filter and search your queue to manage to find specific downloads in your queue.DownThemAll! comes with a button that will allow you to quickly access it's main features, but it can be configured to be a OneClick! button instead.Add downloads from your context menu, e.g. the link, image or video you clicked, or only from queue from the part of the website you selected.DownThemAll! is also present in your tools menu, so you still have full access to its features even when you configured it to not show the context menu and changed the button to OneClick!Of course, you can manually add downloads, too.Batch downloads are supported as well.DownThemAll! comes with powerful preferences that let power users make the most of the extension, but also provides sensible defaults for people who just want to download quickly.

Предпросмотр DownThemAll!

DownThemAll will help you select, queue, sort and run your downloads faster. It comes with advanced ways to select what links to download, and will remember your previous decisions so that you can queue more downloads with just OneClick!

Advanced users will also like using renaming masks, which let you automatically assign names (and even sub-folders within your downloads folder), fast-filtering or even custom, re-usable filters.

DownThemAll is open-source and free. We spend a lot of time making it, and keep spending a lot of time improving it, and even fixing some problems in Firefox itself so DownThemAll! can work even better.
We will never add adware, spyware, user tracking or other nasty stuff. Therefore we rely on your donations exclusively to fund the development.

Читайте также:  Grub rescue linux что делать

We are looking for people willing to help translate DownThemAll! to more languages. For a small guide on how to do that, please see our preliminary translation guide. You will get our gratitude, and the gratitude of all the users whose live you improved by bringing DownThemAll! to their language.

Please do NOT report any bugs and issues in the user review section, but file a bug report instead. This is the only way to make sure we actually see it, and it also makes communicating to us/with you a lot easier. Thanks

Please note: Version 4 of DownThemAll! is.a complete rewrite as a WebExtension, as the old add-on system was abandoned and disabled in Firefox. This was mozilla’s decision, and there is nothing we can do about it. We are therefore limited to the tools the WebExtensions model provides to us, which sadly makes it impossible to provide some of the advanced features of DownThemAll! Version 3. Furthermore there are some bugs in Firefox that affect DownThemAll! as well, e.g. downloads will always succeed even if the server returns an error, but I fixed this in upcoming Firefox 71.
However, we’re still able to provide the advanced selection, queuing, file naming options of the old DownThemAll! and a lot more.

DownThemAll! Beta versions are available from downthemall.org. We urge people willing to help out with testing to have a look. Please note that these preview versions on our homepage were NOT fully reviewed by mozilla yet.

Сообщить о нарушении правил этим дополнением

Если вы считаете, что это дополнение нарушает политики Mozilla в отношении дополнений, или имеет проблемы с безопасностью или приватностью, сообщите об этих проблемах в Mozilla, используя эту форму.

Не используйте эту форму, чтобы сообщать об ошибках или запрашивать новые функции в дополнении; это сообщение будет отправлено в Mozilla, а не разработчику дополнения.

Разработчик этого расширения просит вас помочь поддержать его дальнейшее развитие, внеся небольшое пожертвование.

  • Загружать файлы, а также читать и изменять историю загрузок браузера
  • Открывать файлы, загруженные на ваш компьютер
  • Получать доступ к истории браузера
  • Показывать вам уведомления
  • Получать доступ к недавно закрытым вкладкам
  • Получать доступ ко вкладкам браузера
  • Получать доступ к активности браузера при навигации
  • Получать доступ к вашим данных на всех сайтах
  • Updated Spanish translation (thanks to the translator!)
  • Updated Portuguese-Portugal translation (thanks to the translator!)
  • Improved translation auto-selection.
    This may result in some users that previously saw the English translation (that is picked automatically when no more specific translation can be determined) to see a different translation more in accordance with their browser language.
    Users can still change their preferred translation in the DTA preferences to any other translation that DTA contains.
  • Some code still relied on the wrong translation functions, which in very rare circumstances may have lead to e.g. the wrong file type icons being disabled.

Источник

How to shutdown Linux distros on WSL

If you use WSL, you can use a couple of commands to shut down one or all Linux distros manually, and here’s how.

Читайте также:  Установка firefox для линукс

WSL 2 shutdown Linux distros

Although the Windows Subsystem for Linux (WSL) is a convenient way to run Linux distros alongside Windows 11 or Windows 10, the lightweight virtual machine will continue to run in the background even when you exit the command shell, wasting system resources.

If you prefer to terminate the Linux distro (Ubuntu, Kali, Debian, Mint, etc.) as soon as you are done using it or have to restart it, use a wsl.exe command-line tool to shut down one or all distributions manually.

This guide will teach you the steps to shut down Linux distros running on the WSL2 platform on Windows 10 and 11.

Terminate a Linux distro on WSL

To terminate a Linux distro on WSL running on Windows 11 or Windows 10, use these steps:

WSL terminate Linux distro command

In the command, replace DISTRO-NAME with the name of the distro you want to shut down, as shown in step 3. For example, wsl -t Ubuntu-20.04 .
(Optional) Type the following command to confirm the distro is “stopped” and press Enter:

Once you complete the steps, the distro running on the Windows Subsystem for Linux will gracefully shut down. You can always repeat the steps to terminate other distros or use the steps below to shut them all down.

Terminate all Linux distros on WSL

To shut down all the WSL distros running on Windows 10 (or 11), use these steps:

  1. Open Start.
  2. Search for Command Prompt (or PowerShell), right-click the top result, and select the Run as administrator option.
  3. Type the following command to view all running WSL distros and press Enter:

WSL shutdown all Linux distros command

(Optional) Type the following command to confirm the distros are “stopped,” and press Enter:

After you complete the steps, all the WSL distros will terminate immediately on Windows 11 or 10.

If you need to restart the Linux distro, spin it again from the Start menu, or use Command Prompt or PowerShell and run the wsl —distribution DISTRO-NAME command (replace the DISTRO-NAME with the actual name of the distro before running the command).

We may earn commission for purchases using our links to help keep offering the free content. Privacy policy info.

All content on this site is provided with no warranties, express or implied. Use any information at your own risk. Always backup of your device and files before making any changes. Privacy policy info.

Since you are here.

I’ve got a small favor to ask. This is an independent site, and producing content takes a lot of hard work. Although more people are reading Pureinfotech, many use adblocker. Thus advertising revenue is falling fast. And unlike many other sites, there is no paywall blocking readers here. So you can see why your help is needed. If everyone who finds this website useful and helps to support it, the future would be much more secure. Thank you.

If you use adblocker, please disable it for this site.

$125 raised so far by 11 people.

Источник

Оцените статью
Adblock
detector