Giter Club home page Giter Club logo

hss's Introduction

hss

Release Build Status License: MIT

简体中文README

What's hss?

hss is an interactive ssh client for multiple servers. It will provide almost the same experience as in the bash environment. It supports:

  • interactive input: based on libreadline.
  • history: responding to the C-r key.
  • auto-completion: completion from remote server on the tab key, for commands and paths.

Command is executed on all servers in parallel. Execution on one server does not need to wait for that on another server to finish before starting. So we can run a command on hundreds of servers at the same time.

A quick start

Usage: hss [-f hostfile] [-o file] [-u username] [command]...

Options:
  -f file        file with the list of hosts
  -H host        specifies a host option, support the same options as the ssh command
  -l limit       number of multiple ssh to perform at a time (default: unlimited)
  -u user        the default user name to use when connecting to the remote server
  -c opts        specify the common ssh options (i.e. '-p 22 -i identity_file')
  -o file        write remote command output to a file
  -i             force use a vi-style line editing interface
  -v             be more verbose
  -V             show program version
  -h             display this message

For more information, see https://github.com/six-ddc/hss
  • This is a screenshot

asciicast

How to install it?

  • MacOS

    brew install hss
    sudo port selfupdate
    sudo port install hss
  • Linux

    • Install dependency
    ## on CentOS
    yum install readline-devel
    
    ## on Ubuntu / Debian 
    apt-get install libreadline6-dev
    • Compile and install
    make && make install
  • Or you can download the binary release here .

How to use it?

The fundamental of hss is to execute the ssh command for every host, and then show the results on the terminal. So hss supports every argument supported by the ssh command. Following is an example of the hostfile:

192.168.1.1
-p 2222 [email protected]
-p 2222 -i ~/.ssh/identity_file [email protected]
-p 2222 -oConnectTimeout=3 [email protected]

Connect to servers:

# Specify the hostfile directly
hss -f hostfile

# Or pass servers in arguments
hss -H '192.168.1.1' -H '-p 2222 [email protected]' -H '-p 2222 -i ~/.ssh/identity_file [email protected]' -H '-p 2222 -oConnectTimeout=3 [email protected]'

Passthrough of ssh arguments are supported. For example, by specify -c '-oConnectTimeout=3', sessions without a timeout configured will set its timeout on this argument.

Usage of readline

The interactive input is implemented on libreadline, supporting command and path completion from remote, history storage and searching, moving around, etc. (please refer to readline for more)

  • Command history is stored in file ~/.hss_history.
  • Completion of commands and paths are based on the first server in the list.
  • Path completion is available when the first input character is /, ~ or ..

Goals of the future versions

  • Solve the "@" suffix problem on directory symbol-link.

hss's People

Contributors

herbygillot avatar six-ddc avatar zhanglistar 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hss's Issues

ANSI_COLOR_RESET cause abnormal display on ubuntu 18.04

I have find a way to fix this, define color like this

#define ANSI_COLOR_RED     "\033[0;31m"
#define ANSI_COLOR_GREEN   "\033[0;32m"
#define ANSI_COLOR_YELLOW  "\033[0;33m"
#define ANSI_COLOR_BLUE    "\033[0;34m"
#define ANSI_COLOR_MAGENTA "\033[0;35m"
#define ANSI_COLOR_CYAN    "\033[0;36m"

#define ANSI_COLOR_BOLD         "\033[1m"
#define ANSI_COLOR_RED_BOLD     "\033[1;31m"
#define ANSI_COLOR_GREEN_BOLD   "\033[1;31m"
#define ANSI_COLOR_YELLOW_BOLD  "\033[1;31m"
#define ANSI_COLOR_BLUE_BOLD    "\033[1;31m"
#define ANSI_COLOR_MAGENTA_BOLD "\033[1;31m"
#define ANSI_COLOR_CYAN_BOLD    "\033[1;31m"

#define ANSI_COLOR_RESET   "\033[0m"

recipe for target 'all' failed

Hello, I ran into an issue while compiling:

cc -I/usr/local/opt/readline/include -O3 -Wall -lreadline main.o sstring.o slot.o completion.o executor.o -o hss 
main.o: In function `print_version':
main.c:(.text+0x20f): undefined reference to `rl_library_version'
main.o: In function `parse_opts':
main.c:(.text+0x2ca): undefined reference to `rl_editing_mode'
main.o: In function `main':
main.c:(.text.startup+0x6b): undefined reference to `rl_startup_hook'
main.c:(.text.startup+0x76): undefined reference to `rl_readline_name'
main.c:(.text.startup+0x7f): undefined reference to `rl_initialize'
main.c:(.text.startup+0x84): undefined reference to `using_history'
main.c:(.text.startup+0xbc): undefined reference to `read_history'
main.c:(.text.startup+0xc3): undefined reference to `rl_attempted_completion_function'
main.c:(.text.startup+0xef): undefined reference to `rl_reset_screen_size'
main.c:(.text.startup+0x111): undefined reference to `readline'
main.c:(.text.startup+0x159): undefined reference to `add_history'
main.c:(.text.startup+0x163): undefined reference to `write_history'
main.c:(.text.startup+0x17e): undefined reference to `rl_free'
completion.o: In function `filepath_generator':
completion.c:(.text+0xa5): undefined reference to `rl_completion_suppress_append'
completion.c:(.text+0xbe): undefined reference to `rl_completion_suppress_append'
completion.o: In function `remote_filepath_completion_func':
completion.c:(.text+0x219): undefined reference to `rl_completion_matches'
completion.c:(.text+0x229): undefined reference to `rl_attempted_completion_over'
collect2: error: ld returned 1 exit status
Makefile:30: recipe for target 'all' failed
make: *** [all] Error 1

LSB Version: core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:printing-9.20160110ubuntu0.2-amd64:printing-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial

4.15.0-36-generic #39~16.04.1-Ubuntu SMP x86_64

GNU Make 4.1
Built for x86_64-pc-linux-gnu

.bash_profile not read over parallel ssh connection

I'm using hss to connect to 3 Ubuntu servers (the same edition). The problem is on 2 of them ~/.bash_profile is not read over hss, even though it is being read when I ssh in individually to each.

$ env | grep -w PATH
[O] root@example-sql -> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
[O] root@example-www -> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
[O] root@example-search -> PATH=.:/root/bin:/usr/local/node/bin:...

example-search does read .bash_profile apparently, because there are additional directories that I added to PATH, like /root/bin, etc. The first two, however, do not seem to.

Why is that happening? How can I fix that (I want PATH the way I defined it, obviously).

I'm getting the same effect on another group (Debian 8 servers).

File Upload

I love this tool.

there is one thing missing: File Upload

Could you work on it?

Bash script version of hss

Hi, it is very convenient to use your tool!

I also developed a similar tool, written in bash and run on GUI environment.
Its auto-completion is not as powerful as hss.
But it supports executing separate cmd on each ssh session.

Feel free to play with it! https://github.com/tangruize/spssh

How to use with `sudo`?

When running sudo I get:

$ sudo su
[E] test2.example.com -> sudo: no tty present and no askpass program specified
[E] test.example.com -> sudo: no tty present and no askpass program specified
[E] example.com -> sudo: no tty present and no askpass program specified

Is there any way to circumvent this?

Support SSH ProxyJump

## this is ok
ssh  ${ip}

## this is not ok
➜  hosts hss -H ${ip}
$ ls
[E] xxxx -> zsh:1: unknown exec flag -q
[E] xxxx -> ssh_exchange_identification: Connection closed by remote host
$ 

I configured my ssh config with

ProxyJump jump_hosts:26890

Remember changed directories

Very useful tool, thanks a lot for sharing!

I think hss would be even more powerful if there was an option to remember what directories have been traversed during the interactive session. This would make the experience closer to being in an interactive shell.

I'm not sure how best to do this, but a naive approach would be to store the directory after each parralel-ssh command is exited, and then just cd into this directory as the first command on the next parrallel-ssh invocation like so:

parallel-ssh -i -H server "cd /my/previous/dir; my_next_commands"

I would make a PR, but I'm not familiar enough with the code to know where to suggest a change.

Does this feature sound plausible? And if so, do you agree it would be useful?

Thanks,
Dan

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.