Skip to content

Commit

Permalink
Merge pull request #109 from blacknon/develop
Browse files Browse the repository at this point in the history
Version 0.6.8
  • Loading branch information
blacknon authored May 3, 2024
2 parents 234964a + 2c24321 commit 3c68b3d
Show file tree
Hide file tree
Showing 556 changed files with 43,747 additions and 13,998 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# - https://github.com/motemen/lssh/blob/97d3745dcc8931a1d75217573d5ca60705be632f/.github/workflows/release.yml
# - https://github.com/greymd/teip/blob/master/.github/workflows/release.yml


name: Release Job.

on:
Expand Down Expand Up @@ -36,6 +35,10 @@ jobs:
goarch: amd64
os: macos-latest
ext: tar.gz
- goos: darwin
goarch: arm64
os: macos-latest
ext: tar.gz
- goos: windows
goarch: amd64
os: windows-latest
Expand All @@ -44,10 +47,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Go 1.17
- name: Set up Go 1.22
uses: actions/setup-go@v1
with:
go-version: 1.17
go-version: 1.22

- name: Get version
id: package_version
Expand Down Expand Up @@ -198,6 +201,10 @@ jobs:
goarch: amd64
os: macos-latest
ext: tar.gz
- goos: darwin
goarch: arm64
os: macos-latest
ext: tar.gz
- goos: windows
goarch: amd64
os: windows-latest
Expand Down
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
# Go コマンド
GOCMD=go
MODULE=GO111MODULE=on
GOBUILD=$(MODULE) $(GOCMD) build
GOBUILD=$(MODULE) $(GOCMD) build -ldflags -w
GOCLEAN=$(GOCMD) clean
GOTEST=$(MODULE) $(GOCMD) test -cover
GOGET=$(GOCMD) get
GOMOD=$(MODULE) $(GOCMD) mod
GOINSTALL=$(MODULE) $(GOCMD) install

# OS別にbuildのコマンド生成
UNAME_S=$(shell uname -s)
BUILDCMD_LSSH=$(GOBUILD) ./cmd/lssh
BUILDCMD_LSCP=$(GOBUILD) ./cmd/lscp
BUILDCMD_LSFTP=$(GOBUILD) ./cmd/lsftp

build:
# Remove unnecessary dependent libraries
$(GOMOD) tidy
# Place dependent libraries under vendor
$(GOMOD) vendor
# Build lssh
$(GOBUILD) ./cmd/lssh

# Build lsshgo
$(BUILDCMD_LSSH)
# Build lscp
$(GOBUILD) ./cmd/lscp
$(BUILDCMD_LSCP)
# Build lsftp
$(GOBUILD) ./cmd/lsftp
$(BUILDCMD_LSFTP)

clean:
$(GOCLEAN) ./...
Expand All @@ -27,12 +34,17 @@ clean:
rm -f lsftp

install:
# copy lssh binary to /usr/local/bin/
# rm old binary
rm /usr/local/bin/lssh
rm /usr/local/bin/lscp
rm /usr/local/bin/lsftp

# copy binary to /usr/local/bin/
cp lssh /usr/local/bin/
# copy lscp binary to /usr/local/bin/
cp lscp /usr/local/bin/
# copy lsftp binary to /usr/local/bin/
cp lsftp /usr/local/bin/

# copy template config file
cp -n example/config.tml ~/.lssh.conf || true

test:
Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[![TravisCI](https://travis-ci.org/blacknon/lssh.svg?branch=master)](https://travis-ci.org/blacknon/lssh)
[![Go Report Card](https://goreportcard.com/badge/github.com/blacknon/lssh)](https://goreportcard.com/report/github.com/blacknon/lssh)

lssh
Expand All @@ -20,14 +19,13 @@ Supported multiple ssh proxy, http/socks5 proxy, x11 forward, and port forwardin

## Features

* List selection type ssh client.
* List selection type Pure Go ssh client.
* It can run on **Linux**, **macOS** and **Windows**.
* Pure Go.
* Commands can be executed by ssh connection in **parallel**.
* 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**, **Reverse Dynamic Forward** and **x11 forward**.
* Supported **Local** and **Remote Port forward**, **Dynamic Forward(SOCKS5, http)**, **Reverse Dynamic Forward(SOCKS5)** 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 @@ -109,12 +107,14 @@ option(lssh)
--host servername, -H servername connect servername.
--file filepath, -F filepath config filepath. (default: "/Users/uesugi/.lssh.conf")
-L [bind_address:]port:remote_address:port Local port forward mode.Specify a [bind_address:]port:remote_address:port. Only single connection works.
-R [bind_address:]port:remote_address:port Remote port forward mode.Specify a [bind_address:]port:remote_address:port. Only single connection works.
-R [bind_address:]port:remote_address:port 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.
-D port Dynamic port forward mode(Socks5). Specify a port. Only single connection works.
-d port HTTP Dynamic port forward mode. Specify a port. Only single connection works.
-w Displays the server header when in command execution mode.
-W Not displays the server header when in command execution mode.
--not-execute, -N not execute remote command and shell.
--x11, -X x11 forwarding(forward to ${DISPLAY}).
--X11, -X Enable x11 forwarding(forward to ${DISPLAY}).
-Y Enable trusted x11 forwarding(forward to ${DISPLAY}).
--term, -t run specified command at terminal.
--parallel, -p run command parallel node(tail -F etc...).
--localrc use local bashrc shell.
Expand All @@ -128,7 +128,7 @@ option(lssh)
blacknon([email protected])

VERSION:
0.6.7
0.6.8

USAGE:
# connect ssh
Expand All @@ -144,6 +144,7 @@ option(lssh)
lssh -s



### lscp

run command.
Expand All @@ -169,7 +170,7 @@ option(lscp)
blacknon([email protected])

VERSION:
0.6.7
0.6.8

USAGE:
# local to remote scp
Expand Down Expand Up @@ -204,11 +205,12 @@ option(lsftp)
blacknon([email protected])

VERSION:
0.6.7
0.6.8

USAGE:
# start lsftp shell
lsftp
# start lsftp shell
lsftp



If you specify a command as an argument, you can select multiple hosts. Select host <kbd>Tab</kbd>, select all displayed hosts <kbd>Ctrl</kbd> + <kbd>a</kbd>.
Expand Down
6 changes: 2 additions & 4 deletions cmd/lscp/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package main
import (
"fmt"
"os"
"os/user"
"sort"
"strings"

Expand All @@ -21,8 +20,7 @@ import (

func Lscp() (app *cli.App) {
// Default config file path
usr, _ := user.Current()
defConf := usr.HomeDir + "/.lssh.conf"
defConf := common.GetDefaultConfigPath()

// Set help templete
cli.AppHelpTemplate = `NAME:
Expand Down Expand Up @@ -60,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.7"
app.Version = "0.6.8"

// options
// TODO(blacknon): オプションの追加(0.7.0)
Expand Down
Empty file removed cmd/lsftp/.gitkeep
Empty file.
11 changes: 5 additions & 6 deletions cmd/lsftp/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ package main
import (
"fmt"
"os"
"os/user"
"sort"

"github.com/blacknon/lssh/common"
"github.com/blacknon/lssh/conf"
"github.com/blacknon/lssh/list"
"github.com/blacknon/lssh/sftp"
Expand All @@ -18,8 +18,7 @@ import (

func Lsftp() (app *cli.App) {
// Default config file path
usr, _ := user.Current()
defConf := usr.HomeDir + "/.lssh.conf"
defConf := common.GetDefaultConfigPath()

// Set help templete
cli.AppHelpTemplate = `NAME:
Expand All @@ -42,16 +41,16 @@ VERSION:
{{.Version}}
{{end}}
USAGE:
# start lsftp shell
{{.Name}}
# start lsftp shell
{{.Name}}
`
// Create app
app = cli.NewApp()
// app.UseShortOptionHandling = true
app.Name = "lsftp"
app.Usage = "TUI list select and parallel sftp client command."
app.Copyright = "blacknon([email protected])"
app.Version = "0.6.7"
app.Version = "0.6.8"

app.Flags = []cli.Flag{
cli.StringFlag{Name: "file,F", Value: defConf, Usage: "config file path"},
Expand Down
Empty file removed cmd/lssh/.gitkeep
Empty file.
28 changes: 19 additions & 9 deletions cmd/lssh/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.

// TODO: dynamic port forwarding風に http proxyを生やすオプションの追加

package main

import (
"fmt"
"os"
"os/user"
"regexp"
"sort"

Expand All @@ -23,8 +20,7 @@ import (

func Lssh() (app *cli.App) {
// Default config file path
usr, _ := user.Current()
defConf := usr.HomeDir + "/.lssh.conf"
defConf := common.GetDefaultConfigPath()

// Set help templete
cli.AppHelpTemplate = `NAME:
Expand Down Expand Up @@ -66,7 +62,7 @@ USAGE:
app.Name = "lssh"
app.Usage = "TUI list select and parallel ssh client command."
app.Copyright = "blacknon([email protected])"
app.Version = "0.6.7"
app.Version = "0.6.8"

// TODO(blacknon): オプションの追加
// -f ... バックグラウンドでの接続(X11接続やport forwardingをバックグラウンドで実行する場合など)。
Expand All @@ -86,14 +82,17 @@ USAGE:

// port forward option
cli.StringSliceFlag{Name: "L", Usage: "Local port forward mode.Specify a `[bind_address:]port:remote_address:port`. Only single connection works."},
cli.StringSliceFlag{Name: "R", Usage: "Remote port forward mode.Specify a `[bind_address:]port:remote_address:port`. Only single connection works."},
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."},

// Other bool
cli.BoolFlag{Name: "w", Usage: "Displays the server header when in command execution mode."},
cli.BoolFlag{Name: "W", Usage: "Not displays the server header when in command execution mode."},
cli.BoolFlag{Name: "not-execute,N", Usage: "not execute remote command and shell."},
cli.BoolFlag{Name: "x11,X", Usage: "x11 forwarding(forward to ${DISPLAY})."},
cli.BoolFlag{Name: "X11,X", Usage: "Enable x11 forwarding(forward to ${DISPLAY})."},
cli.BoolFlag{Name: "Y", Usage: "Enable trusted x11 forwarding(forward to ${DISPLAY})."},
cli.BoolFlag{Name: "term,t", Usage: "run specified command at terminal."},
cli.BoolFlag{Name: "parallel,p", Usage: "run command parallel node(tail -F etc...)."},
cli.BoolFlag{Name: "localrc", Usage: "use local bashrc shell."},
Expand Down Expand Up @@ -180,7 +179,15 @@ USAGE:
r.IsParallel = c.Bool("parallel")

// x11 forwarding
r.X11 = c.Bool("x11")
enableX11 := c.Bool("X11")
enableTrustedX11 := c.Bool("Y")

if enableX11 || enableTrustedX11 {
r.X11 = true
}
if enableTrustedX11 {
r.X11Trusted = true
}

// is tty
r.IsTerm = c.Bool("term")
Expand Down Expand Up @@ -239,6 +246,9 @@ USAGE:
// Dynamic port forwarding port
r.DynamicPortForward = c.String("D")

// HTTP Dynamic port forwarding port
r.HTTPDynamicPortForward = c.String("d")

r.Start()
return nil
}
Expand Down
32 changes: 28 additions & 4 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func IsExist(filename string) bool {
return err == nil
}

//
func Contains(list interface{}, elem interface{}) bool {
listV := reflect.ValueOf(list)

Expand Down Expand Up @@ -335,9 +334,9 @@ func GetNameFromId(file string, id uint32) (name string, err error) {
// ParseForwardPort return forward address and port from string.
//
// ex.)
// - `localhost:8000:localhost:18000` => local: "localhost:8000", remote: "localhost:18000"
// - `8080:localhost:18080` => local: "localhost:8080", remote: "localhost:18080"
// - `localhost:2222:12222` => local: "localhost:2222", remote: "localhost:12222"
// - `localhost:8000:localhost:18000` => local: "localhost:8000", remote: "localhost:18000"
// - `8080:localhost:18080` => local: "localhost:8080", remote: "localhost:18080"
// - `localhost:2222:12222` => local: "localhost:2222", remote: "localhost:12222"
func ParseForwardPort(value string) (local, remote string, err error) {
// count column
count := strings.Count(value, ":")
Expand Down Expand Up @@ -488,3 +487,28 @@ func StringCompression(mode int, data []byte) (result []byte, err error) {

return
}

func GetDefaultConfigPath() (path string) {
// get XDG_CONFIG_HOME
xdgConfigHome := os.Getenv("XDG_CONFIG_HOME")

// get user
usr, _ := user.Current()

// get home dir
home := usr.HomeDir

// get config path
homeConfigPath := filepath.Join(home, ".lssh.conf")
xdgConfigPath := filepath.Join(xdgConfigHome, "lssh", "lssh.conf")

if _, err := os.Stat(homeConfigPath); os.IsExist(err) {
return homeConfigPath
}

if _, err := os.Stat(xdgConfigPath); os.IsExist(err) {
return xdgConfigPath
}

return homeConfigPath
}
Loading

0 comments on commit 3c68b3d

Please sign in to comment.