sesh

command module
v0.0.0-...-17faf91 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

README

sexy-ssh

Sexy ssh makes batch ssh tasks sexy!

Install

Build from source
git clone git@github.com:qjpcpu/sexy-ssh.git
cd sexy-ssh
export GOPATH=`pwd`
go install sesh

The executable file bin/sesh is all you need.

Download binary file
go get -u github.com/qjpcpu/sesh

Usage

hosts

Use with host file:

sesh -f host-file -u user -p password 'echo hello'

The host-file's format is simple, one host per line, like:

www.example-host00.com
www.example-host01.com

Output is:

output

If the hosts can be counted, you can use -h to specify remote hosts, seperated by ,:

sesh -h www.host1.com,www.host2.com -u user -p password 'echo hello'

Sesh also can get hosts from Stdin:

echo host1,host2 | sesh -u user -p password 'echo hello'
cat host-file | sesh -u user -p password 'echo hello'
Authorization

Use -p to specify password, but it's better to use rsa authorization with -i:

sesh -f host-file -u user -i ~/.ssh/id_rsa 'echo hello'
# Or, just use nothing for authorization, sesh use ~/.ssh/id_rsa as default
sesh -f host-file -u user 'echo hello'

And, if the user of remote host is same as current user, we can just drop -u flag:

sesh -f host-file 'echo hello'

build key auth quickly: sesh -f host-file -u user -c @auth.cmd

Timeout

The default connection timeout is 5 seconds, it can be changed by --timeout:

sesh -f host-file  --timeout 1 'echo hello'
Parallel

Sesh would execute job for each host serially by default, swith -r on for parallel execution:

sesh -f host-file -r 'echo hello'

Sesh would execute all task by parallel,if you want control the parallel degree, you could use --parallel-degree.

Output is:

output

Forexample, if you want execute every 2 hosts by paraallel:

sesh -f host-file -r --parallel-degree 2 'echo hello'
Check for sure

If you want have a check after the first host's job done, you can use --check, when first job done, you would auto logon the first host, if everything is fine, press Ctrl+Dto return and continue.

sesh -f host-file --check 'touch new-file'
Execute script

If you want execute many commands on remote host, you would find it's hard to use ssh command to accomplish that, so you can put these comands into a file, for example keygen.cmd:

if [ ! -e "~/.ssh/id_rsa" ];then
    ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
fi

Use -c to specity command file:

sesh -f host-list -c keygen.cmd

If the script needs arguments, the --exec might help. Note: the first symbol {} represents the script file name.

sesh -f host-list  -c myscript.cmd  --exec 'sh {} hello'

the content of myscript.cmd is echo "say $1", so the output would be say hello.

If the script starts with shibang #!, forexample, a ruby file test.rb is:

#!/usr/bin/ruby
puts "say "+ARGV.to_s

You can run sesh like this:

sesh -f host-list -c test.rb --exec '{} hello'
Command template

You can embedded parameter in command or command file with {{ name }}, then invoke sesh with -d, for example, there is a command file enter-today-dir.cmd:

cd ~/{{ date }}/logs && pwd

then, we can use sesh like this:

sesh -f hosts -d date=$(date +%Y%m%d) -c enter-today-dir.cmd

You can also use argument parse for inline commands:

sesh -f hosts -d who=jason 'echo {{ who }} is sexy'

Or you can invoke script(the first line must start with #!) with arguments in normal way:

This is a ruby script x.rb:

#!/usr/bin/ruby
puts ARGV

Now the sesh would be:

sesh -f hosts -c x.rb --exec "{} hello"
Remote cp(scp)

Sesh also support scp

sesh -f hosts send -s srcfile -d /remote/directory
Help
sesh --help

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package gocui allows to create console user interfaces.
Package gocui allows to create console user interfaces.
golang.org
x/crypto/bcrypt
Package bcrypt implements Provos and Mazières's bcrypt adaptive hashing algorithm.
Package bcrypt implements Provos and Mazières's bcrypt adaptive hashing algorithm.
x/crypto/blowfish
Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
x/crypto/bn256
Package bn256 implements a particular bilinear group at the 128-bit security level.
Package bn256 implements a particular bilinear group at the 128-bit security level.
x/crypto/cast5
Package cast5 implements CAST5, as defined in RFC 2144.
Package cast5 implements CAST5, as defined in RFC 2144.
x/crypto/curve25519
Package curve25519 provides an implementation of scalar multiplication on the elliptic curve known as curve25519.
Package curve25519 provides an implementation of scalar multiplication on the elliptic curve known as curve25519.
x/crypto/hkdf
Package hkdf implements the HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as defined in RFC 5869.
Package hkdf implements the HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as defined in RFC 5869.
x/crypto/md4
Package md4 implements the MD4 hash algorithm as defined in RFC 1320.
Package md4 implements the MD4 hash algorithm as defined in RFC 1320.
x/crypto/nacl/box
Package box authenticates and encrypts messages using public-key cryptography.
Package box authenticates and encrypts messages using public-key cryptography.
x/crypto/nacl/secretbox
Package secretbox encrypts and authenticates small messages.
Package secretbox encrypts and authenticates small messages.
x/crypto/ocsp
Package ocsp parses OCSP responses as specified in RFC 2560.
Package ocsp parses OCSP responses as specified in RFC 2560.
x/crypto/openpgp
Package openpgp implements high level operations on OpenPGP messages.
Package openpgp implements high level operations on OpenPGP messages.
x/crypto/openpgp/armor
Package armor implements OpenPGP ASCII Armor, see RFC 4880.
Package armor implements OpenPGP ASCII Armor, see RFC 4880.
x/crypto/openpgp/clearsign
Package clearsign generates and processes OpenPGP, clear-signed data.
Package clearsign generates and processes OpenPGP, clear-signed data.
x/crypto/openpgp/elgamal
Package elgamal implements ElGamal encryption, suitable for OpenPGP, as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms," IEEE Transactions on Information Theory, v.
Package elgamal implements ElGamal encryption, suitable for OpenPGP, as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms," IEEE Transactions on Information Theory, v.
x/crypto/openpgp/errors
Package errors contains common error types for the OpenPGP packages.
Package errors contains common error types for the OpenPGP packages.
x/crypto/openpgp/packet
Package packet implements parsing and serialization of OpenPGP packets, as specified in RFC 4880.
Package packet implements parsing and serialization of OpenPGP packets, as specified in RFC 4880.
x/crypto/openpgp/s2k
Package s2k implements the various OpenPGP string-to-key transforms as specified in RFC 4800 section 3.7.1.
Package s2k implements the various OpenPGP string-to-key transforms as specified in RFC 4800 section 3.7.1.
x/crypto/otr
Package otr implements the Off The Record protocol as specified in http://www.cypherpunks.ca/otr/Protocol-v2-3.1.0.html
Package otr implements the Off The Record protocol as specified in http://www.cypherpunks.ca/otr/Protocol-v2-3.1.0.html
x/crypto/pbkdf2
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
x/crypto/pkcs12
Package pkcs12 implements some of PKCS#12.
Package pkcs12 implements some of PKCS#12.
x/crypto/pkcs12/internal/rc2
Package rc2 implements the RC2 cipher https://www.ietf.org/rfc/rfc2268.txt http://people.csail.mit.edu/rivest/pubs/KRRR98.pdf This code is licensed under the MIT license.
Package rc2 implements the RC2 cipher https://www.ietf.org/rfc/rfc2268.txt http://people.csail.mit.edu/rivest/pubs/KRRR98.pdf This code is licensed under the MIT license.
x/crypto/poly1305
Package poly1305 implements Poly1305 one-time message authentication code as specified in http://cr.yp.to/mac/poly1305-20050329.pdf.
Package poly1305 implements Poly1305 one-time message authentication code as specified in http://cr.yp.to/mac/poly1305-20050329.pdf.
x/crypto/ripemd160
Package ripemd160 implements the RIPEMD-160 hash algorithm.
Package ripemd160 implements the RIPEMD-160 hash algorithm.
x/crypto/salsa20
Package salsa20 implements the Salsa20 stream cipher as specified in http://cr.yp.to/snuffle/spec.pdf.
Package salsa20 implements the Salsa20 stream cipher as specified in http://cr.yp.to/snuffle/spec.pdf.
x/crypto/salsa20/salsa
Package salsa provides low-level access to functions in the Salsa family.
Package salsa provides low-level access to functions in the Salsa family.
x/crypto/scrypt
Package scrypt implements the scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions" (http://www.tarsnap.com/scrypt/scrypt.pdf).
Package scrypt implements the scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions" (http://www.tarsnap.com/scrypt/scrypt.pdf).
x/crypto/sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
x/crypto/ssh
Package ssh implements an SSH client and server.
Package ssh implements an SSH client and server.
x/crypto/ssh/agent
Package agent implements a client to an ssh-agent daemon.
Package agent implements a client to an ssh-agent daemon.
x/crypto/ssh/terminal
Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.
Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.
x/crypto/ssh/test
This package contains integration tests for the github.com/qjpcpu/sesh/golang.org/x/crypto/ssh package.
This package contains integration tests for the github.com/qjpcpu/sesh/golang.org/x/crypto/ssh package.
x/crypto/twofish
Package twofish implements Bruce Schneier's Twofish encryption algorithm.
Package twofish implements Bruce Schneier's Twofish encryption algorithm.
x/crypto/xtea
Package xtea implements XTEA encryption, as defined in Needham and Wheeler's 1997 technical report, "Tea extensions."
Package xtea implements XTEA encryption, as defined in Needham and Wheeler's 1997 technical report, "Tea extensions."
x/crypto/xts
Package xts implements the XTS cipher mode as specified in IEEE P1619/D16.
Package xts implements the XTS cipher mode as specified in IEEE P1619/D16.

Jump to

Keyboard shortcuts

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