Code Monkey home page Code Monkey logo

csshi's Introduction

csshi

A ClusterSSH utility (like cssh) for iTerm2.

The command opens an iTerm2 Window and connects over ssh to each specified host in a split pane session, with any text typed or pasted replicated to all panes through iTerm2's 'broadcast' feature by default. iTerm2's split pane controls are available as normal, so broadcast input can be toggled per-pane, sessions can be restarted, etc.

Screenshot

Install

Homebrew

  • Install iTerm2 however you like.
  • Install csshi:
    $ brew install ilikejam/csshi/csshi
  • Enable the iTerm2 Python API at:
    iTerm2 -> Settings... -> General -> Magic
    The 'Require "Automation" permission' option is OK.

Manual

  • Install iTerm2 however you like.
  • Install python3 e.g. with homebrew:
    $ brew install python3
  • Install the python iterm2 and pyobjc libs through pip:
    $ pip3 install iterm2 pyobjc
  • Clone this repo (or just download the 'csshi' file), make the csshi file executable, and maybe copy or link it to somewhere in your $PATH.
  • Enable the iTerm2 Python API at:
    iTerm2 -> Settings... -> General -> Magic
    The 'Require "Automation" permission' option is OK.

Usage

usage: csshi [-h] [-l USERNAME] [-p PORT] [-d] [-J JUMPHOST] [-o OPTIONS]
             [-C COLUMNS] [-k] [-b BINARY] [-s SLEEP] [-n]
             destination [destination ...]

Run multiple ssh connections concurrently in an iTerm2 terminal.

positional arguments:
  destination           [user@]host[:port] ssh server specification. Use
                        square brackets around IPv6 IP adresses.

options:
  -h, --help            show this help message and exit
  -l USERNAME, --username USERNAME
                        Login username, overridden per-host by specifying
                        'user@host'
  -p PORT, --port PORT  ssh server port, overridden per-host by specifying
                        'host:port
  -d, --debug           Turn on debugging
  -J JUMPHOST, --jump JUMPHOST
                        ProxyJump host specification, like
                        [user@]jumphost[:port]
  -o OPTIONS, --options OPTIONS
                        Raw ssh options string, e.g. '-i ~/.ssh/id_ansible'
  -C COLUMNS, --columns COLUMNS
                        Maximum number of columns.
  -k, --kill-inactive   Don't create spacer panes and kill inactive panes
  -b BINARY, --binary BINARY
                        SSH binary to use. Defaults to 'ssh'
  -s SLEEP, --sleep SLEEP
                        Sleep time in seconds between hosts. Defaults to 0
  -n, --no-broadcast    Don't enable input broadcast

Tips

If you have a file listing hostnames to connect to, use xargs:
$ cat file_of_hosts | xargs csshi

Some preferences to optimise for shell density if you find yourself opening a lot of terminals in one csshi session:

  • Disable pane menubars:
    iTerm2 -> Preferences... -> Appearance -> Panes -> Show per-pane title bar with split panes
    You can still access the menu for each pane with Ctrl-click instead of the menubar burger icon
  • Use a small font, like the original misc-fixed 6x13, and disable antialiasing:
    iTerm2 -> Preferences... -> Profiles -> Text -> Anti-aliased
  • Decrease the 'Side' and 'Top & bottom' margins:
    iTerm2 -> Preferences... -> Appearance -> Panes

If you are connecting to large numbers of hosts via a single Jumphost, it's advisable to set up multiplexing for the Jumphost:
https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing
Also consider raising MaxConnections on that host - the default on OpenSSH is 10.

Contribute

Throw a PR over, raise an issue, send me an email.

csshi's People

Contributors

ilikejam avatar vedarthk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

csshi's Issues

Close panes with ended session

Hi and thanks for the script. Is it possible to autclose inactive session? For ex. I use it like this:
csshi myserver{01..99}.mydomain and it spins out several panes, but a lot of them are unreachable/nonexistent servers.
It would be nice if it could autoclose the inactive panes. I tried to set profile.set_close_sessions_on_end(False) to false in gen_ssh_profile() but it messed up something and it didn't work as espected.

Thanks!

Custom ssh command

Hi!
I'd like to be possible to specify a custom ssh command or (maybe better) respect shell aliases.
I have an alias for ssh to sshrc (a script useful to bring shell custom settings to remote servers without touching root bash profiles). But as I can see csshi just run ssh command + arguments without using the aliased command. For the moment I've just modified to ssh_string variable to use sshrc but it would be nice to have the option.

Thanks,
Luca

Missing python module on installation

I just want to add that i needed to install this module:

pip3 install pyobjc

for csshi to work. If not python gives error about missing AppKit module, but if you install AppKit with pip it ends up with a mess. I took me quite a bit of research to make it work.

Read hostnames from file

This tool would be perfect if it could read hostnames from a file, in addition to taking a list at the command line.

Something like a -file or -hosts argument.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.