Skip to content

Commit

Permalink
Merge pull request #135 from blacknon/develop
Browse files Browse the repository at this point in the history
Version 0.6.9
  • Loading branch information
blacknon authored Jul 6, 2024
2 parents 9c1b566 + e60d13c commit 32a7c0a
Show file tree
Hide file tree
Showing 59 changed files with 238 additions and 11,189 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
# - docker

go:
- 1.12.x
- 1.22.x

git:
depth: 1
Expand Down
50 changes: 14 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ List file is set in yaml format.
When selecting a host, you can filter by keywords.
Can execute commands concurrently to multiple hosts.

lssh also has a shell (parallel shell) that connects to multiple hosts at the same time and pipes the execution results of local commands and remote hosts.
In addition, lsftp also has a shell that can be connected in parallel.
lsftp shells can be connected in parallel.

Supported multiple ssh proxy, http/socks5 proxy, x11 forward, and port forwarding.

Expand All @@ -25,7 +24,7 @@ Supported multiple ssh proxy, http/socks5 proxy, x11 forward, and port forwardin
* There is a shell function that connects to multiple hosts in parallel for interactive operation and connects with local commands via pipes.
* Supported multiple proxy, **ssh**, **http**, and **socks5** proxy. It's supported multi-stage proxy.
* Supported **ssh-agent**.
* Supported **Local** and **Remote Port forward**, **Dynamic Forward(SOCKS5, http)**, **Reverse Dynamic Forward(SOCKS5)** and **x11 forward**.
* Supported **Local** and **Remote Port forward**, **Dynamic Forward(SOCKS5, http)**, **Reverse Dynamic Forward(SOCKS5, http)** and **x11 forward**.
* Can use bashrc of local machine at ssh connection destination.
* It supports various authentication methods. Password, Public key, Certificate and PKCS11(Yubikey etc.).
* Can read the OpenSSH config (~/.ssh/config) and use it as it is.
Expand Down Expand Up @@ -140,11 +139,6 @@ option(lssh)
# run command parallel in selected server over ssh.
lssh -p command...

# run command parallel in selected server over ssh, do it in interactively shell.
lssh -s



### lscp

run command.
Expand Down Expand Up @@ -300,7 +294,7 @@ There are other parameters corresponding to ClientAliveInterval and ClientAliveC

</details>

### 2. [lssh] run command (parallel)
### 2. [lssh] run command (with parallel)
<details>

It is possible to execute by specifying command in argument.\
Expand Down Expand Up @@ -336,27 +330,7 @@ Can be piped to send Stdin.

</details>

### 3. [lssh] Execute commands interactively (parallel shell)
<details>

You can send commands to multiple servers interactively.

<p align="center">
<img src="./images/3-1.gif" />
</p>

# parallel shell connect
lssh -s


You can also combine remote and local commands.

remote_command | !local_command


</details>

### 4. [lscp] scp (local=>remote(multi), remote(multi)=>local, remote=>remote(multi))
### 3. [lscp] scp (local=>remote(multi), remote(multi)=>local, remote=>remote(multi))
<details>

You can do scp by selecting a list with the command lscp.\
Expand Down Expand Up @@ -386,7 +360,7 @@ You can select multiple connection destinations. This program use sftp protocol.

</details>

### 5. [lsftp] sftp (local=>remote(multi), remote(multi)=>local)
### 4. [lsftp] sftp (local=>remote(multi), remote(multi)=>local)
<details>

You can do sftp by selecting a list with the command lstp.\
Expand All @@ -402,7 +376,7 @@ You can select multiple connection destinations.
</details>


### 6. include ~/.ssh/config file.
### 5. include ~/.ssh/config file.
<details>

Load and use `~/.ssh/config` by default.\
Expand All @@ -417,7 +391,7 @@ Alternatively, you can specify and read the path as follows: In addition to the

</details>

### 7. include other ServerConfig file.
### 6. include other ServerConfig file.
<details>

You can include server settings in another file.\
Expand Down Expand Up @@ -459,7 +433,7 @@ The priority of setting values ​​is as follows.

</details>

### 8. Supported Proxy
### 7. Supported Proxy
<details>

Supports multiple proxy.
Expand Down Expand Up @@ -530,7 +504,7 @@ Besides this, you can also specify ProxyCommand like OpenSSH.
</details>


### 9. Available authentication method
### 8. Available authentication method
<details>

* Password auth
Expand Down Expand Up @@ -612,7 +586,7 @@ Besides this, you can also specify ProxyCommand like OpenSSH.
</details>


### 10. Port forwarding
### 9. Port forwarding
<details>

Supported Local/Remote/Dynamic port forwarding.\
Expand Down Expand Up @@ -665,6 +639,10 @@ If OpenSsh config is loaded, it will be loaded as it is.

</details>

## Related projects

- [go-sshlib](github.com/blacknon/go-sshlib)
- [lsshell](github.com/blacknon/lsshell)

## Licence

Expand Down
2 changes: 1 addition & 1 deletion cmd/lscp/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ USAGE:
app.Name = "lscp"
app.Usage = "TUI list select and parallel scp client command."
app.Copyright = "blacknon([email protected])"
app.Version = "0.6.8"
app.Version = "0.6.9"

// options
// TODO(blacknon): オプションの追加(0.7.0)
Expand Down
2 changes: 1 addition & 1 deletion cmd/lsftp/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ USAGE:
app.Name = "lsftp"
app.Usage = "TUI list select and parallel sftp client command."
app.Copyright = "blacknon([email protected])"
app.Version = "0.6.8"
app.Version = "0.6.9"

app.Flags = []cli.Flag{
cli.StringFlag{Name: "file,F", Value: defConf, Usage: "config file path"},
Expand Down
11 changes: 5 additions & 6 deletions cmd/lssh/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ USAGE:
# run command parallel in selected server over ssh.
{{.Name}} -p command...
# run command parallel in selected server over ssh, do it in interactively shell.
{{.Name}} -s
`

// Create app
Expand All @@ -62,7 +59,7 @@ USAGE:
app.Name = "lssh"
app.Usage = "TUI list select and parallel ssh client command."
app.Copyright = "blacknon([email protected])"
app.Version = "0.6.8"
app.Version = "0.6.9"

// TODO(blacknon): オプションの追加
// -f ... バックグラウンドでの接続(X11接続やport forwardingをバックグラウンドで実行する場合など)。
Expand All @@ -85,7 +82,7 @@ USAGE:
cli.StringSliceFlag{Name: "R", Usage: "Remote port forward mode.Specify a `[bind_address:]port:remote_address:port`. If only one port is specified, it will operate as Reverse Dynamic Forward. Only single connection works."},
cli.StringFlag{Name: "D", Usage: "Dynamic port forward mode(Socks5). Specify a `port`. Only single connection works."},
cli.StringFlag{Name: "d", Usage: "HTTP Dynamic port forward mode. Specify a `port`. Only single connection works."},
// cli.StringFlag{Name: "r", Usage: "HTTP Reverse Dynamic port forward mode. Specify a `port`. Only single connection works."},
cli.StringFlag{Name: "r", Usage: "HTTP Reverse Dynamic port forward mode. Specify a `port`. Only single connection works."},

// Other bool
cli.BoolFlag{Name: "w", Usage: "Displays the server header when in command execution mode."},
Expand All @@ -97,7 +94,6 @@ USAGE:
cli.BoolFlag{Name: "parallel,p", Usage: "run command parallel node(tail -F etc...)."},
cli.BoolFlag{Name: "localrc", Usage: "use local bashrc shell."},
cli.BoolFlag{Name: "not-localrc", Usage: "not use local bashrc shell."},
cli.BoolFlag{Name: "pshell,s", Usage: "use parallel-shell(pshell) (alpha)."},
cli.BoolFlag{Name: "list,l", Usage: "print server list from config."},
cli.BoolFlag{Name: "help,h", Usage: "print this help"},
}
Expand Down Expand Up @@ -249,6 +245,9 @@ USAGE:
// HTTP Dynamic port forwarding port
r.HTTPDynamicPortForward = c.String("d")

// HTTP Reverse Dynamic port forwarding port
r.HTTPReverseDynamicPortForward = c.String("r")

r.Start()
return nil
}
Expand Down
Empty file removed cmd/s/.gitkeep
Empty file.
4 changes: 4 additions & 0 deletions conf/conf_struct_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ type ServerConfig struct {
// ex.) "11080"
HTTPDynamicPortForward string `toml:"http_dynamic_port_forward"`

// HTTP Reverse Dynamic Port Forward setting
// ex.) "11080"
HTTPReverseDynamicPortForward string `toml:"http_reverse_dynamic_port_forward"`

// x11 forwarding setting
X11 bool `toml:"x11"`

Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/blacknon/lssh

go 1.22.2
go 1.22.4

toolchain go1.22.5

// require
require (
Expand All @@ -11,20 +13,18 @@ require (
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 // indirect
github.com/blacknon/go-sshlib v0.1.11
github.com/blacknon/go-sshlib v0.1.12
github.com/blacknon/go-x11auth v0.1.0 // indirect
github.com/blacknon/textcol v0.0.1
github.com/c-bata/go-prompt v0.2.6
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect
github.com/disiqueira/gotree v1.0.0
github.com/dustin/go-humanize v1.0.0
github.com/elazarl/goproxy v0.0.0-20231117061959-7cc037d33fb5 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/kevinburke/ssh_config v0.0.0-20190724205821-6cfae18c12b8
github.com/kr/fs v0.1.0 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
Expand All @@ -48,7 +48,6 @@ require (
golang.org/x/sys v0.19.0
golang.org/x/term v0.19.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
mvdan.cc/sh v2.6.3+incompatible
)

// replace
Expand Down
16 changes: 2 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/blacknon/crypto11 v1.2.6 h1:Mv+Boto0qVR1O2k5lmoCYcyXfiQYY7mQ1P/TcK5Tw
github.com/blacknon/crypto11 v1.2.6/go.mod h1:HThRIRjHpJIJwcExGgNuPCyf26HqcFVTTAnipaXWz7M=
github.com/blacknon/go-prompt v0.2.7 h1:dVdTqVplKvpT/k4bB9BlbcBYl/k6amYX5tvjYBmuKkI=
github.com/blacknon/go-prompt v0.2.7/go.mod h1:zNBmC/BPAyr+3ey1oRhPxuXJS9zz1lEmJpwaoQroe3w=
github.com/blacknon/go-sshlib v0.1.11 h1:cUaAb9Cv0PI9OyQ1xJTz5hvJRki8Jqgf90n4F0MYxOc=
github.com/blacknon/go-sshlib v0.1.11/go.mod h1:GvW6dUsuVG4dcmyqYv40H773YUsUK8MGHdsoQxbtr6M=
github.com/blacknon/go-sshlib v0.1.12 h1:K66DzwzF5RhlKQjcda0R7/FbvslXOayVd75UVzCKfZQ=
github.com/blacknon/go-sshlib v0.1.12/go.mod h1:EqEKtFd4DInkF3Ryx+YXnj70u7pJenVr4H3uEGEgoHI=
github.com/blacknon/go-x11auth v0.1.0 h1:SnljCPWcvglWeGAlKc1RAPMHnOfMpM9+GrTGEUQ1lqQ=
github.com/blacknon/go-x11auth v0.1.0/go.mod h1:SKOCa19LluXHyB+OaLYobquzceE0SWxVW7e/qU5xGBM=
github.com/blacknon/textcol v0.0.1 h1:x9h7yLPGyr8Pdz12XJ30h7Iz5mJlKd0CzfGYxhrmnk8=
Expand All @@ -29,10 +29,6 @@ github.com/disiqueira/gotree v1.0.0 h1:en5wk87n7/Jyk6gVME3cx3xN9KmUCstJ1IjHr4Se4
github.com/disiqueira/gotree v1.0.0/go.mod h1:7CwL+VWsWAU95DovkdRZAtA7YbtHwGk+tLV/kNi8niU=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/elazarl/goproxy v0.0.0-20231117061959-7cc037d33fb5 h1:m62nsMU279qRD9PQSWD1l66kmkXzuYcnVJqL4XLeV2M=
github.com/elazarl/goproxy v0.0.0-20231117061959-7cc037d33fb5/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
Expand All @@ -43,11 +39,6 @@ github.com/kevinburke/ssh_config v0.0.0-20190724205821-6cfae18c12b8 h1:AUkD9wwFc
github.com/kevinburke/ssh_config v0.0.0-20190724205821-6cfae18c12b8/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
Expand Down Expand Up @@ -80,7 +71,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
github.com/sevlyar/go-daemon v0.1.5 h1:Zy/6jLbM8CfqJ4x4RPr7MJlSKt90f00kNM1D401C+Qk=
github.com/sevlyar/go-daemon v0.1.5/go.mod h1:6dJpPatBT9eUwM5VCw9Bt6CdX9Tk6UWvhW3MebLDRKE=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down Expand Up @@ -137,5 +127,3 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
mvdan.cc/sh v2.6.3+incompatible h1:uXnnFNSBQbKUwwh2iBSkVjG+GbwoMuI+UmBVPnNiWhA=
mvdan.cc/sh v2.6.3+incompatible/go.mod h1:IeeQbZq+x2SUGBensq/jge5lLQbS3XT2ktyp3wrt4x8=
5 changes: 5 additions & 0 deletions sftp/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,12 @@ func (r *RunSftp) exitChecker(in string, breakline bool) bool {
}

if len(r.Client) == 0 {
// error messages
fmt.Printf("Error: No valid connections\n")

// TODO: 再接続が発生する場合はexitせずに返す?
os.Exit(1)

return true
}

Expand Down
15 changes: 13 additions & 2 deletions ssh/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,16 @@ func (r *Run) cmd() (err error) {
config.ReverseDynamicPortForward = r.ReverseDynamicPortForward
}

// OverWrite dynamic port forwarding
// OverWrite http dynamic port forwarding
if r.HTTPDynamicPortForward != "" {
config.HTTPDynamicPortForward = r.HTTPDynamicPortForward
}

// OverWrite reverse http dynamic port forwarding
if r.HTTPReverseDynamicPortForward != "" {
config.HTTPReverseDynamicPortForward = r.HTTPReverseDynamicPortForward
}

// OverWrite local bashrc use
if r.IsBashrc {
config.LocalRcUse = "yes"
Expand Down Expand Up @@ -150,6 +155,12 @@ func (r *Run) cmd() (err error) {
go c.HTTPDynamicForward("localhost", config.HTTPDynamicPortForward)
}

// HTTP Reverse Dynamic Port Forwarding
if config.HTTPReverseDynamicPortForward != "" {
r.printHTTPReverseDynamicPortForward(config.HTTPReverseDynamicPortForward)
go c.HTTPReverseDynamicForward("localhost", config.HTTPReverseDynamicPortForward)
}

// if tty
if r.IsTerm {
c.Stdin = os.Stdin
Expand All @@ -172,7 +183,7 @@ func (r *Run) cmd() (err error) {
go output.PushInput(exitInput, writers, os.Stdin)

case !r.IsParallel && len(r.ServerList) > 1:
if r.isStdinPipe {
if r.IsStdinPipe {
stdinData, _ = ioutil.ReadAll(os.Stdin)
}
}
Expand Down
Loading

0 comments on commit 32a7c0a

Please sign in to comment.