Skip to main content

A Python package to execute code remotely to multiple operating system platforms

Project description

rudder

rudder is a Python package to run commands remotely on Windows, macOS or *nix systems using PowerShell Remoting/WinRM or SSH.

Getting Started

In order to use rudder you must make sure you have access and credentials to authenticate to a remote host.

Prerequisites

The following packages will be installed and are prerequisities for rudder:

paramiko
fire
pypsrp

NOTE: To use this on your remote Windows machines, you need to do the following:

  1. Run from an elevated PowerShell prompt
winrm quickconfig (type yes)
Enable-PSRemoting (type yes)
# Set start mode to automatic
Set-Service WinRM -StartMode Automatic
# Verify start mode and state - it should be running
Get-WmiObject -Class win32_service | Where-Object {$_.name -like "WinRM"}
  1. Additionally you may need to specify the allowed host to remote into systems:
# Trust hosts
Set-Item 'WSMan:localhost\client\trustedhosts' -value * -Force 
NOTE: don't use the * for the value parameter in production - specify your Swimlane instance IP
# Verify trusted hosts configuration
Get-Item WSMan:\localhost\Client\TrustedHosts
  1. Additional Troubleshooting
#If you receive a timeout error or something like that, check and make sure that your remote Windows host network is set to Private and NOT public. You can change it using the following:

# Get Network Profile
Get-NetConnectionProfile

# if the NetworkCategory is set to Public then run the following to set it to Private

Set-NetConnectionProfile -InterfaceAlias Ethernet0 -NetworkCategory Private
# try it again

Installing

Install this package using pip:

pip3 install rudder

Or you can clone this repository and install locally:

git clone https://github.com/MSAdministrator/rudder.git
cd rudder
python3 setup.py install

Usage

Below contains two prime examples of using rudder on both Windows and a *nix system.

Whether you are wanting to run a command remotely on Windows or a *nix based system (e.g. CentOS, macOS, etc.) you first need to create a HostInfo object. You do this by importing the HostInfo class in your script like so:

from rudder import HostInfo

Windows HostInfo Object

You first need to provide the following information when instantiating a HostInfo object for Windows systems:

from rudder import HostInfo

windows_host = '10.0.0.0'
windows_username = 'Administrator'
windows_pass = 'somepassword'

hostinfo = HostInfo().windows(
    windows_host,
    windows_username,
    windows_pass
)

*Nix HostInfo Object

You first need to provide the following information when instantiating a HostInfo object for *nix systems:

from rudder import HostInfo

nix_host = '10.0.0.0'
nix_username = 'root'
nix_pass = 'somepassword'
# Optionally you can provide the following parameters:
# ssh_key_path = '/Users/username/.ssh/id_rsa'
# port = '2222'

hostinfo = HostInfo().linux(
    nix_host,
    nix_username,
    password=nix_pass
    ssh_key_path=None,
    port=22
)

Running Command Remotely on Windows

With rudder you can run either cmd or powershell commands remotely. Below are two examples of these methods:

from rudder import Rudder, HostInfo

windows_host = '10.0.0.0'
windows_username = 'Administrator'
windows_pass = 'somepassword'

hostinfo = HostInfo().windows(
    windows_host,
    windows_username,
    windows_pass
)

conductor = Rudder().execute(hostinfo, 'powershell', 'Get-ChildItem -Path "C:\" -Recurse')
print(conductor)
conductor = Rudder().execute(hostinfo, 'cmd', 'dir')
print(conductor)

Running Command Remotely on *Nix

With rudder you can run commands remotely using SSH and whichever shell is avaialble on the remote system:

from rudder import Rudder, HostInfo

nix_host = '10.0.0.0'
nix_username = 'root'
nix_pass = 'somepassword'

hostinfo = HostInfo().linux(
    nix_host,
    nix_username,
    password=nix_pass
)
conductor = Rudder().execute(hostinfo, 'ssh', 'ls -al')
print(conductor)

Built With

  • carcass - Python packaging template

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rudder-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rudder-0.1.0-py3.6.egg (22.8 kB view details)

Uploaded Egg

rudder-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file rudder-0.1.0.tar.gz.

File metadata

  • Download URL: rudder-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for rudder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 102ce68198dcf8cf8859a93c37920e973702d16a67e31499e05cba473c9373b7
MD5 0a0aa2d9cbefccb8b45432e413ca78e2
BLAKE2b-256 9e17acc3ba5cb7479eb37eeb2ac3c7f472857fd56af16a4dbae02d260870e4b7

See more details on using hashes here.

File details

Details for the file rudder-0.1.0-py3.6.egg.

File metadata

  • Download URL: rudder-0.1.0-py3.6.egg
  • Upload date:
  • Size: 22.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.20.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.5

File hashes

Hashes for rudder-0.1.0-py3.6.egg
Algorithm Hash digest
SHA256 e6459b733b620c7dec981afd060e04798f63ee4073af1525fbe8271e43ba1865
MD5 15e94ebd13b6b0868324df9021f65577
BLAKE2b-256 703a13c23c7757fa3d16b09d0a4f69a11e04ca59eff4c22a426c7048eda76e80

See more details on using hashes here.

File details

Details for the file rudder-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rudder-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for rudder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15eacc38495decb0f5cf8da7a240ad3f0a9f92fbbb3e78bd53d5b1f6722483a8
MD5 32ab845eb1da840865e8aeb84173a786
BLAKE2b-256 3eb701942eb0888ead7f9d69f204da5d7578e2957a19e45c5d09b21dbd33bf2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page