Execute commands on multiple remote SSH sessions
Project description
ssh_session_manager
Execute commands on multiple remote SSH sessions
Example 1: Using the SSHSession
from ssh_session_manager.Command import Command
from ssh_session_manager.SSHSession import SSHSession
ls_command = Command("ls -la")
ps_command = Command("ps -ax")
commands = [
ls_command,
ps_command
]
with SSHSession("Silver Server", "10.0.0.57", "user", "password") as ssh_session:
for command in commands:
ssh_session.run_command_in_ssh_session(command)
command_output_dictionary = ssh_session.get_command_output_dictionary(ps_command)
standard_output_lines = command_output_dictionary["standard_output_lines"]
standard_error_lines = command_output_dictionary["standard_error_lines"]
exit_status = command_output_dictionary["exit_status"]
Example 2: Using the SSHSessionManager
from ssh_session_manager.Command import Command
from ssh_session_manager.SSHSession import SSHSession
from ssh_session_manager.SSHSessionManager import SSHSessionManager
ssh_session_1 = SSHSession("Silver Server", "10.0.0.57", "user", "password")
ssh_session_2 = SSHSession("Black Server", "10.0.0.58", "user", "password")
ssh_sessions = [
ssh_session_1,
ssh_session_2
]
ls_command = Command("ls -la")
ps_command = Command("ps -ax")
commands = [
ls_command,
ps_command
]
with SSHSessionManager(ssh_sessions) as ssh_session_manager
ssh_session_manager.run_commands_in_ssh_sessions(commands)
command_output_dictionary = ssh_session_manager.get_command_output_dictionary(ssh_session_1, ls_command)
standard_output_lines = command_output_dictionary["standard_output_lines"]
standard_error_lines = command_output_dictionary["standard_error_lines"]
exit_status = command_output_dictionary["exit_status"]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for ssh-session-manager-0.5.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbddbd87f9dec0a21a43981f024475a65610c6669d6291452f83c79acb92178f |
|
MD5 | 61558efd68748daa071821035013f35b |
|
BLAKE2b-256 | 7d7fbce660dd5017498d0d5701a478568ff76662891cfadc30d358701985d42c |