Multithreaded_SSH V0.5.0

Multithreaded_SSH V0.5.0 has been released.

The code is now open source on Github.

An .exe executable file has also been packaged. Feel free to download it if needed.

The executable file is packaged using pyinstaller. Not sure why it is flagged by antivirus software like 360. If you have concerns, you can package it yourself.

Release Notes:

  1. Added the ability to read from Excel. You can now retrieve host addresses, usernames, commands, and terminators from an Excel file.
  2. Improved code modularity.
  3. Optimized code logic.

Usage Instructions:

  1. Prepare files:

    • TXT mode: Make sure there are two files in the same directory as the program: host.txt and commands.txt. As the names suggest, host.txt should contain the addresses of remote hosts (one address per line), and commands.txt should contain the commands to be executed (one command per line).

    • Excel mode: Ensure there is an SSH.xlsx file in the program’s directory, or manually input the file name. The Excel file format can be found in the example file on GitHub. The requirements are as follows:

      • The header should include Hostname, Address, Username, Multi_SSH_Enable, and cmd1. Optional:end*.

      • Command numbers should be consecutive without skipping any. For example, cmd1, cmd2, cmd3, cmd5. Commands starting from cmd5 and beyond will be ignored. The end numbers can be non-consecutive, and they correspond to the termination indicators for the commands with the same number.

      Hostname Address Username Multi_SSH_Enable cmd1 end1
      Hostname Address Username Enable Flag
      True: Enabled
      False: Disabled
      Leave empty for enabled
      Command Command Terminator

      If you are using the source code, make sure the excel_read.py file is in the directory.

  2. Ensure that the program has permissions to create directories and files. After execution, the program will create two directories and several log files:

    • log
      • year-month-day.log
      • Paramiko-year-month-day.log
    • SSH_log
      • year-month-day-host_address.log

    year-month-day.log is used to store the program’s output logs, where you can check the program’s execution status.

    Paramiko-year-month-day.log stores the logs generated by Paramiko, which can be useful for debugging SSH connection issues.

    year-month-day-host_address.log is used to store the output of each connected host after SSH connection.

  3. When you open the program, it will prompt you to enter the device password. The password will not be displayed on the terminal.

  4. During program execution, it will provide real-time information and summaries. However, if there are many devices, the output may appear messy. You can review the program logs after completion.

Note:

  1. Although this version resolves the issue of not being able to customize terminators mentioned in v0.1.1, it still retains the ability to use \n in commands to represent a newline.
  2. In TXT mode or if hostnames are not defined in the Excel file, an attempt will be made to define the hostname using the characters between < and >. If unsuccessful, the host will be skipped.
  3. In TXT mode or if end is not defined in the Excel file, the default interruption indicator will be <device_name or [device_name.

Update Plans:

The code is entering a stable phase, and there are no planned updates in the near future unless issues are discovered or minor modifications are required.

Conclusion:

While coding, I accidentally discovered that Python supports using Chinese characters as variables, which led to this fun version.

Feel free to exchange thoughts in the comment section below or directly submit issues on GitHub.

If you find this program useful, you can give it a 👍 below or give it a ⭐ on Github. Thank you for your support.

This article was translated by ChatGPT.

0%