Skip to content

cloud-and-smart-labs/butter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Butter 🧈 - SSH Client

Lightweight SSH-Client. Build to manage IoT devices (like Raspberry Pis) VMs, Systems. It is agentless and relies on SSH Infrastructure. Fully capable of remotely executing commands on inventories and fetching you the consolidated outputs.

Table of Contents

Requirments

  • Works with Unix-based systems (Linux, macOS)
  • Python 3.7 or higher
  • SSH passwordless login

Secure Shell Setup

Generate SSH Key Pair

The system running Butter should be able to login into each device through SSH without a password. So, generate SSH key pair and copy the public key to all other devices.

ssh-keygen

Copy the Public Key

ssh-copy-id pi@192.168.0.XXX

Installation

  1. Clone the butter repository
git clone https://github.com/cloud-and-smart-labs/butter.git
  1. Install the package
pip install butter

Enabling Command Auto-completion

  • Linux Systems (Bash Shell)
_BUTTER_COMPLETE=bash_source butter > ~/.butter-complete.bash && echo '. ~/.butter-complete.bash' >> ~/.bashrc && source ~/.bashrc
  • MacOS (zsh Shell)
    The completion system needs to be activated. Add the following to your ~/.zshrc or ~/.zprofile
autoload -Uz compinit
compinit

Then enabling Auto-completion

echo 'eval "$(_BUTTER_COMPLETE=zsh_source butter)"' >> ~/.zprofile && source ~/.zprofile &&  echo 'eval "$(_BUTTER_COMPLETE=zsh_source butter)"' >> ~/.zprofile && source ~/.zprofile

Walk Through

Butter has two types of commands:

  1. inventory: Creates inventory that contains the SSH details of hosts
  2. Execute: Executes the commands on inventories
butter --help

Inventory

  1. Create inventory demo
butter inventory create demo
butter inventory create demo_1 demo_2 demo_3
  1. Add hosts into the inventory demo
butter inventory add demo root@172.17.0.3 root@172.17.0.4
  1. Get list of inventories
butter inventory ls
butter inventory ls -a
  1. Get list of Hosts inside inventory
butter inventory ls demo

butter inventory ls demo_1 demo_2 
  1. Remove host from inventory
butter inventory rm demo 172.17.0.3 172.17.0.4

OR

butter inventory rm demo root@172.17.0.3 root@172.17.0.4
  1. Remove inventory demo
butter inventory clear demo 

Clear all

butter inventory clear -a

Execute

Execute commands

butter exe sh demo 'docker image ls'

-s: Serially Stream

butter exe sh demo 'docker image ls' -s

OR use shorter one
bx : butter execute

bx demo 'docker image ls'
bx demo 'docker image ls' -s

License

This tool is licensed under the Apache License 2.0.