lssh

command module
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2018 License: MIT Imports: 2 Imported by: 0

README

CircleCI

lssh

TUI list select ssh/scp client.

Description

command to read a prepared list in advance and connect ssh/scp the selected host. List file is set in yaml format.When selecting a host, you can filter by keywords. Can execute commands concurrently to multiple hosts. Supported multiple ssh proxy, and supported http/socks5 proxy.

Demo

Requirement

lscp is need the following command in remote server.

  • scp

Install

compile gofile(tested go1.8.3).

go get github.com/blacknon/lssh
cd $GOPATH/src/github.com/blacknon/lssh
make && sudo make install && make clean

brew install(Mac OS X)

brew tap blacknon/lssh
brew install lssh

# generate .lssh.conf(not use ~/.ssh/config)
curl -s https://raw.githubusercontent.com/blacknon/lssh/master/example/config.tml | cp -n <(cat) ~/.lssh.conf # copy sample config file

# generate .lssh.conf(use ~/.ssh/config.not support proxy)
lssh --generate > ~/.lssh.conf

Usage

Please edit "~/.lssh.conf". The connection information at servers,can be divided into external files. log dir "<Date>" => date(YYYYMMDD) ,"<Hostname>" => Servername.

example:

# terminal log settings
[log]
enable = true
timestamp = true
dirpath = "/path/to/logdir"

# server common settings
[common] 
port = "22"
user = "test"

# include config file settings and path (only common,server config).
[include.Name]
path = "/path/to/include/file"

[server.PasswordAuth_ServerName]
addr = "192.168.100.101"
pass = "Password"
note = "Password Auth Server"

[server.KeyAuth_ServerName]
addr = "192.168.100.102"
user = "test-user"
key  = "/path/to/private_key"
note = "Key Auth Server"

[server.LocalCommand_ServerName]
addr = "192.168.100.103"
key  = "/path/to/private_key"
note = "Before/After run local command"
pre_cmd = "(option) exec command before ssh connect."
post_cmd = "(option) exec command after ssh disconnected."

[server.UseLocalBashrc_ServerName]
addr = "192.168.100.104"
key  = "/path/to/private_key"
note = "Use local bashrc files."
pre_cmd = "(option) exec command before ssh connect."
local_rc = 'yes'
local_rc_file = [
     "~/dotfiles/.bashrc"
    ,"~/dotfiles/bash_prompt"
    ,"~/dotfiles/sh_alias"
    ,"~/dotfiles/sh_export"
    ,"~/dotfiles/sh_function"
]

[server.sshProxyServer]
addr = "192.168.100.200"
key  = "/path/to/private_key"
note = "proxy server"

[server.overProxyServer]
addr = "192.168.10.10"
key  = "/path/to/private_key"
note = "connect use ssh proxy"
proxy = "sshProxyServer"

[server.overProxyServer2]
addr = "192.168.10.100"
key  = "/path/to/private_key"
note = "connect use ssh proxy(multiple)"
proxy = "overProxyServer"

[server.overHttpProxy]
addr = "over-http-proxy.com"
key  = "/path/to/private_key"
note = "connect use http proxy"
proxy = "HttpProxy"
proxy_type = "http"

[server.overSocks5Proxy]
addr = "192.168.10.101"
key  = "/path/to/private_key"
note = "connect use socks5 proxy"
proxy = "Socks5Proxy"
proxy_type = "socks5"

[proxy.HttpProxy]
addr = "example.com"
port = "8080"

[proxy.Socks5Proxy]
addr = "example.com"
port = "54321"

After run command.

lssh

option(lssh)

NAME:
	lssh - TUI list select and parallel ssh client command.
USAGE:
	lssh [options] [commands...]

OPTIONS:
    --host value, -H value  connect servernames
    --list, -l              print server list from config
    --file value, -f value  config file path (default: "$HOME/.lssh.conf")
    --term, -t              run specified command at terminal
    --parallel, -p          run command parallel node(tail -F etc...)
    --generate              (beta) generate .lssh.conf from .ssh/config.(not support ProxyCommand)
    --help, -h              print this help
    --version, -v           print the version

COPYRIGHT:
	blacknon(blacknon@orebibou.com)

VERSION:
	0.5.1

USAGE:
	# connect ssh
	lssh

	# parallel run command in select server over ssh
	lssh -p command...

option(lscp)

NAME:
    lscp - TUI list select and parallel scp client command.
USAGE:
    lscp [options] (local|remote):from_path... (local|remote):to_path

OPTIONS:
    --host value, -H value  connect servernames
    --list, -l              print server list from config
    --file value, -f value  config file path (default: "$HOME/.lssh.conf")
    --permission, -p        copy file permission
    --help, -h              print this help
    --version, -v           print the version

COPYRIGHT:
    blacknon(blacknon@orebibou.com)

VERSION:
    0.5.1

USAGE:
    # local to remote scp
    lscp /path/to/local... /path/to/remote

    # remote to local scp
    lscp remote:/path/to/remote... /path/to/local

If you specify a command as an argument, you can select multiple hosts. Select host 'Tab', select all displayed hosts 'Ctrl + A'.

[lssh] copy files using stdin/stdout, and to/from remote server

You can scp like copy files using stdin/stdout.It also supports multiple nodes(parallel is not yet supported now).

# from local to remote server
cat LOCAL_PATH | lssh 'cat > REMOTE_PATH'

# from remote server to local
lssh cat REMOTE_PATH | cat > LOCAL_PATH

[lssh] multiple node select, exec tail -f
# -p option parallel exec command
lssh -p cmd

[lssh] ssh connect, and change Terminal theme.

sample lssh.conf

[server.iTerm2_sample]
addr = "192.168.100.103"
key  = "/path/to/private_key"
note = "Before/After run local command"
pre_cmd = 'printf "\033]50;SetProfile=dq\a"' # ssh theme 
post_cmd = 'printf "\033]50;SetProfile=Default\a"' # local theme
post_cmd = "(option) exec command after ssh disconnected."
[lssh] use local bashrc file.

sample lssh.conf(bash only).

[server.localrc]
addr = "192.168.100.104"
key  = "/path/to/private_key"
note = "Use local bashrc files."
local_rc = 'yes'
local_rc_file = [
     "~/dotfiles/.bashrc"
    ,"~/dotfiles/bash_prompt"
    ,"~/dotfiles/sh_alias"
    ,"~/dotfiles/sh_export"
    ,"~/dotfiles/sh_function"
]
[lscp] scp remote to local (get)

exec lscp get file/dir (remote to local scp).

lscp remote:/path/to/remote local:/path/to/local

# short version
lscp r:/path/to/remote l:/path/to/local
lscp r:/path/to/remote /path/to/local
[lscp] scp local to remote (put)

exec lscp put file/dir (local to remote scp). If multiple server selected, mkdir servername dir.

lscp local:/path/to/remote remote:/path/to/local

# short version
lscp l:/path/to/local r:/path/to/remote
lscp /path/to/local r:/path/to/remote
[lscp] scp remote to remote

exec lscp get/put file/dir (remote to remote scp).

lscp remote:/path/to/remote(get) remote:/path/to/remote(put)

# short version
lscp r:/path/to/remote(get) r:/path/to/local(put)

Licence

A short snippet describing the license MIT.

Author

blacknon

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL