Skip to content

Commit 1c262e7

Browse files
authored
Merge pull request #162 from blacknon/develop
Version 0.8.0
2 parents f80e42e + 36d113b commit 1c262e7

File tree

242 files changed

+32869
-917
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+32869
-917
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/lscp
1919
/lsftp
2020
/lsmon
21+
/lsmux
2122
/lsshell
22-
/lsshfs
2323
/lssync
2424
*.exe

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ UNAME_S=$(shell uname -s)
1313
BUILDCMD_LSSH=$(GOBUILD) ./cmd/lssh
1414
BUILDCMD_LSCP=$(GOBUILD) ./cmd/lscp
1515
BUILDCMD_LSFTP=$(GOBUILD) ./cmd/lsftp
16+
BUILDCMD_LSSYNC=$(GOBUILD) ./cmd/lssync
1617
BUILDCMD_LSMON=$(GOBUILD) ./cmd/lsmon
1718
BUILDCMD_LSSHELL=$(GOBUILD) ./cmd/lsshell
1819

1920
# install path
2021
INSTALL_PATH_LSSH=/usr/local/bin/lssh
2122
INSTALL_PATH_LSCP=/usr/local/bin/lscp
2223
INSTALL_PATH_LSFTP=/usr/local/bin/lsftp
24+
INSTALL_PATH_LSSYNC=/usr/local/bin/lssync
2325
INSTALL_PATH_LSSHELL=/usr/local/bin/lsshell
2426
INSTALL_PATH_LSMON=/usr/local/bin/lsmon
2527
build:
@@ -34,6 +36,8 @@ build:
3436
$(BUILDCMD_LSCP)
3537
# Build lsftp
3638
$(BUILDCMD_LSFTP)
39+
# Build lssync
40+
$(BUILDCMD_LSSYNC)
3741
# Build lsmon
3842
$(BUILDCMD_LSMON)
3943
# Build lsshell
@@ -44,6 +48,7 @@ clean:
4448
rm -f lssh
4549
rm -f lscp
4650
rm -f lsftp
51+
rm -f lssync
4752
rm -f lsmon
4853
rm -f lsshell
4954

@@ -52,13 +57,15 @@ install:
5257
[ -e $(INSTALL_PATH_LSSH) ] && rm $(INSTALL_PATH_LSSH) || true
5358
[ -e $(INSTALL_PATH_LSCP) ] && rm $(INSTALL_PATH_LSCP) || true
5459
[ -e $(INSTALL_PATH_LSFTP) ] && rm $(INSTALL_PATH_LSFTP) || true
60+
[ -e $(INSTALL_PATH_LSSYNC) ] && rm $(INSTALL_PATH_LSSYNC) || true
5561
[ -e $(INSTALL_PATH_LSSHELL) ] && rm $(INSTALL_PATH_LSSHELL) || true
5662
[ -e $(INSTALL_PATH_LSMON) ] && rm $(INSTALL_PATH_LSMON) || true
5763

5864
# copy binary to /usr/local/bin/
5965
cp lssh $(INSTALL_PATH_LSSH)
6066
cp lscp $(INSTALL_PATH_LSCP)
6167
cp lsftp $(INSTALL_PATH_LSFTP)
68+
cp lssync $(INSTALL_PATH_LSSYNC)
6269
cp lsshell $(INSTALL_PATH_LSSHELL)
6370
cp lsmon $(INSTALL_PATH_LSMON)
6471

README.md

Lines changed: 138 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ lssh is a pure Go, list-oriented SSH toolkit that lets you select hosts from a T
1515

1616
### Features
1717

18-
- Pure Go SSH toolkit with cross-platform support for Linux, macOS, and Windows
1918
- Host inventory defined in TOML, with interactive filtering and selection
2019
- SSH, SCP, and SFTP workflows from a single tool suite
2120
- Parallel operations across multiple hosts, including command execution and interactive shells
@@ -25,7 +24,7 @@ lssh is a pure Go, list-oriented SSH toolkit that lets you select hosts from a T
2524
- Authentication support for password, public key, certificate, PKCS#11, and `ssh-agent`
2625
- OpenSSH config import, known_hosts support
2726
- ControlMaster/ControlPersist session reuse
28-
27+
- Pure Go SSH toolkit with cross-platform support for Linux, macOS, and Windows
2928

3029
### Commands
3130

@@ -36,7 +35,9 @@ The `lssh` suite provides multiple commands for different SSH-related workflows.
3635
| [lssh](./cmd/lssh/README.md) | Interactive SSH access and port forwarding | TUI-based SSH client for host selection, interactive login, parallel command execution, and forwarding features. |
3736
| [lsftp](./cmd/lsftp/README.md) | Interactive file operations over SFTP | Interactive SFTP shell for browsing directories, transferring files, and managing one or more hosts together. |
3837
| [lscp](./cmd/lscp/README.md) | SCP-style file transfer | File transfer command for local-to-remote, remote-to-local, and remote-to-remote copy operations over SSH. |
38+
| [lssync](./cmd/lssync/README.md) | One-way sync over SSH/SFTP | Sync command for mirroring local or remote trees to a destination, with optional delete behavior. |
3939
| [lsshell](./cmd/lsshell/README.md) | Sending commands to multiple hosts | Parallel interactive shell that can broadcast commands to selected hosts from a single prompt. |
40+
| [lsmux](./cmd/lsmux/README.md) | Managing multiple SSH sessions in panes | Tmux-like SSH multiplexer that opens selected hosts in a pane-based TUI, supports command panes and file transfer, and keeps multiple remote sessions visible at once. |
4041
| [lsmon](./cmd/lsmon/README.md) | Monitoring multiple remote hosts | TUI monitor that displays CPU, memory, disk, network, and process information from multiple hosts side by side. |
4142

4243

@@ -50,6 +51,65 @@ If you want to try the main connection patterns locally, see [demo/README.md](./
5051

5152
You can install `lssh` with `go install`, Homebrew, or by building from source.
5253

54+
### Prebuilt binaries
55+
56+
Prebuilt binaries are available on GitHub Releases.
57+
58+
#### Linux (amd64, tar.gz)
59+
60+
<details>
61+
62+
Install to `/usr/local/bin`:
63+
64+
```bash id="1c8m19"
65+
VERSION=0.7.1
66+
curl -fL -o /tmp/lssh.tar.gz \
67+
"https://github.com/blacknon/lssh/releases/download/v${VERSION}/lssh_${VERSION}_linux_amd64.tar.gz"
68+
sudo tar -xzf /tmp/lssh.tar.gz -C /tmp
69+
sudo install -m 0755 /tmp/lssh_${VERSION}_linux_amd64/bin/* /usr/local/bin/
70+
```
71+
72+
</details>
73+
74+
#### Debian / Ubuntu (.deb)
75+
76+
<details>
77+
78+
```bash
79+
VERSION=0.7.1
80+
curl -fL -o /tmp/lssh.deb \
81+
"https://github.com/blacknon/lssh/releases/download/v${VERSION}/lssh_${VERSION}_amd64.deb"
82+
sudo apt install /tmp/lssh.deb
83+
```
84+
85+
</details>
86+
87+
#### RHEL / Fedora / Rocky / AlmaLinux (.rpm)
88+
89+
<details>
90+
91+
```bash
92+
VERSION=0.7.1
93+
curl -fL -o /tmp/lssh.rpm \
94+
"https://github.com/blacknon/lssh/releases/download/v${VERSION}/lssh-${VERSION}-1.x86_64.rpm"
95+
sudo dnf install -y /tmp/lssh.rpm
96+
```
97+
98+
</details>
99+
100+
#### Package layout
101+
102+
`lssh` provides both a full suite package and smaller split packages.
103+
104+
| Package | Includes | Best for |
105+
| --- | --- | --- |
106+
| `lssh_*` | `lssh`, `lscp`, `lsftp`, `lssync`, `lsmon`, `lsshell`, `lsmux` | Full installation of the entire tool suite |
107+
| `lssh-core_*` | `lssh` | SSH access and forwarding only |
108+
| `lssh-transfer_*` | `lscp`, `lsftp`, `lssync` | File transfer workflows only |
109+
| `lssh-monitor_*` | `lsmon` | Monitoring multiple remote hosts |
110+
| `lssh-sysadmin_*` | `lsshell`, `lsmux` | Parallel shell / multi-host operations |
111+
112+
53113
### go install
54114

55115
Install the latest version directly with Go.
@@ -58,34 +118,34 @@ Install the latest version directly with Go.
58118
go install github.com/blacknon/lssh/cmd/lssh@latest
59119
go install github.com/blacknon/lssh/cmd/lscp@latest
60120
go install github.com/blacknon/lssh/cmd/lsftp@latest
61-
go install github.com/blacknon/lssh/cmd/lshell@latest
121+
go install github.com/blacknon/lssh/cmd/lssync@latest
122+
go install github.com/blacknon/lssh/cmd/lsshell@latest
62123
go install github.com/blacknon/lssh/cmd/lsmon@latest
63124
```
64125

65-
### build from source
126+
### brew install
66127

67-
Build from the repository when you want to work from the local source tree.
128+
Install with Homebrew on macOS.
68129

69130
```bash
70-
GO111MODULE=auto go get -u github.com/blacknon/lssh/cmd/lssh
71-
GO111MODULE=auto go get -u github.com/blacknon/lssh/cmd/lscp
72-
GO111MODULE=auto go get -u github.com/blacknon/lssh/cmd/lsftp
73-
GO111MODULE=auto go get -u github.com/blacknon/lssh/cmd/lsshell
74-
GO111MODULE=auto go get -u github.com/blacknon/lssh/cmd/lsmon
131+
brew install blacknon/lssh/lssh
75132
```
76133

77-
### brew install
134+
### build from source
78135

79-
Install with Homebrew on macOS.
136+
Build from the repository when you want to work from the local source tree.
80137

81138
```bash
82-
brew install blacknon/lssh/lssh
139+
git clone https://github.com/blacknon/lssh.git
140+
cd lssh
141+
make build
142+
sudo make install
83143
```
84144

85145
## Usage
86146

87147
This section describes shared configuration features used across the `lssh` suite.
88-
For command-specific features and CLI usage, see [cmd/README.md](/Users/blacknon/_go/src/github.com/blacknon/lssh/cmd/README.md) and the README in each command directory.
148+
For command-specific features and CLI usage, see [cmd/README.md](cmd/README.md) and the README in each command directory.
89149

90150
### TUI navigation and key bindings
91151

@@ -425,13 +485,76 @@ note = "reuse ssh session"
425485

426486
</details>
427487

488+
489+
### conditional overrides with `match`
490+
<details>
491+
492+
Use `[server.<name>.match.<branch>]` when you want to override only part of a host configuration under specific conditions.
493+
Each match branch can change fields such as `proxy`, `user`, `port`, `note`, or `ignore`.
494+
All matching branches are evaluated in ascending `priority` order, and later branches overwrite earlier ones.
495+
This lets you split conditions such as `network`, `os`, and `terminal` into separate layers.
496+
497+
```toml
498+
[server.app]
499+
addr = "192.168.100.50"
500+
user = "demo"
501+
key = "~/.ssh/id_rsa"
502+
note = "direct by default"
503+
504+
[server.app.match.office_network]
505+
priority = 1
506+
when.local_ip_in = ["192.168.100.0/24"]
507+
proxy = "ssh-bastion"
508+
note = "use bastion from office network"
509+
510+
[server.app.match.macos]
511+
priority = 50
512+
when.os_in = ["darwin"]
513+
when.term_in = ["iterm2"]
514+
when.env_in = ["SSH_AUTH_SOCK"]
515+
when.env_value_in = ["TERM_PROGRAM=iTerm.app"]
516+
user = "demo-mac"
517+
note = "prefer macOS + iTerm2 settings"
518+
519+
[server.app.match.outside_office]
520+
priority = 90
521+
when.local_ip_not_in = ["192.168.100.0/24"]
522+
ignore = true
523+
```
524+
525+
In this example, `app` connects directly by default.
526+
When the client is inside `192.168.100.0/24`, the `office_network` branch first overrides the host and routes the connection through `ssh-bastion`.
527+
If the client is also running `lssh` on macOS inside iTerm2, `SSH_AUTH_SOCK` exists, and `TERM_PROGRAM=iTerm.app`, the later `macos` branch additionally overrides `user` and `note`.
528+
When the client is outside that network, `outside_office` hides the host from selection.
529+
530+
Available `when.*` keys:
531+
532+
- `local_ip_in`, `local_ip_not_in`
533+
- `gateway_in`, `gateway_not_in`
534+
- `username_in`, `username_not_in`
535+
- `hostname_in`, `hostname_not_in`
536+
- `os_in`, `os_not_in`
537+
- `term_in`, `term_not_in`
538+
- `env_in`, `env_not_in`
539+
- `env_value_in`, `env_value_not_in`
540+
541+
Notes:
542+
543+
- Lower `priority` values are applied first. Higher `priority` values win when the same field is set multiple times.
544+
- `os_*` matches `runtime.GOOS` values such as `darwin`, `linux`, or `windows`.
545+
- `term_*` mainly matches normalized values from `TERM_PROGRAM` and `TERM` such as `iterm2`, `apple_terminal`, `xterm`, or `tmux`.
546+
- `env_*` checks whether the named environment variables exist.
547+
- `env_value_*` matches exact `KEY=value` pairs.
548+
549+
</details>
550+
428551
## Related projects
429552

430553
- [go-sshlib](https://github.com/blacknon/go-sshlib) ... A Go library for SSH connections, command execution, and interactive shell handling.
431554

432555
## Licence
433556

434-
A short snippet describing the license [MIT](https://github.com/blacknon/lssh/blob/master/LICENSE.md).
557+
A short snippet describing the license [MIT](LICENSE.md).
435558

436559
## Author
437560

cmd/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Each command has its own `main.go` and delegates the actual application logic to
1212
- [`lsshell`](./lsshell/README.md): An interactive shell for sending commands to multiple hosts at the same time.
1313
- [`lsftp`](./lsftp/README.md): An interactive SFTP shell for working with one or more hosts from a single interface.
1414
- [`lscp`](./lscp/README.md): A file transfer client that provides an SCP-style interface.
15+
- [`lssync`](./lssync/README.md): A one-way sync command over SSH/SFTP with optional destination pruning.
1516
- [`lsmon`](./lsmon/README.md): A TUI monitor for viewing the status of multiple hosts side by side.
1617

1718
<!-- Note:
1819
以下のコマンドは後々作っていく
1920
2021
- lsmux ... v0.8.0
21-
- lssync ... v0.8.0
2222
- lsshfs ... v0.8.0
2323
-->

cmd/lscp/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ USAGE:
2323
lscp [options] (local|remote):from_path... (local|remote):to_path
2424

2525
OPTIONS:
26-
--host servername, -H servername connect servernames
27-
--list, -l print server list from config
28-
--file filepath, -F filepath config file path (default: "/Users/blacknon/.lssh.conf")
29-
--parallel value, -P value parallel file copy count per host (default: 1)
30-
--permission, -p copy file permission
31-
--help, -h print this help
32-
--version, -v print the version
26+
--host value, -H value connect servernames
27+
--list, -l print server list from config
28+
--file value, -F value config file path (default: "/Users/blacknon/.lssh.conf")
29+
--parallel value, -P value parallel file copy count per host (default: 1)
30+
--permission, -p copy file permission
31+
--help, -h print this help
32+
--version, -v print the version
3333

3434
COPYRIGHT:
3535
blacknon(blacknon@orebibou.com)
3636

3737
VERSION:
38-
lssh-suite 0.7.0 (stable/core)
38+
lssh-suite 0.8.0 (stable/transfer)
3939

4040
USAGE:
4141
# local to remote scp
@@ -46,6 +46,7 @@ USAGE:
4646

4747
# remote to remote scp
4848
lscp remote:/path/to/remote... remote:/path/to/local
49+
4950
```
5051
5152
## OverView

cmd/lsftp/README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@ USAGE:
2020
lsftp [options]
2121

2222
OPTIONS:
23-
--file filepath, -F filepath config file path (default: "/Users/blacknon/.lssh.conf")
24-
--help, -h print this help
25-
--version, -v print the version
23+
--file value, -F value config file path (default: "/Users/blacknon/.lssh.conf")
24+
--help, -h print this help
25+
--version, -v print the version
2626

2727
COPYRIGHT:
2828
blacknon(blacknon@orebibou.com)
2929

3030
VERSION:
31-
lssh-suite 0.7.0 (stable/core)
31+
lssh-suite 0.8.0 (stable/transfer)
3232

3333
USAGE:
3434
# start lsftp shell
3535
lsftp
36+
3637
```
3738
3839
## OverView
@@ -56,6 +57,7 @@ lsftp -F ~/.lssh.conf
5657
5758
- Download files with `get`
5859
- Upload files with `put`
60+
- Sync files with `sync`
5961
- Copy files between remote hosts with `copy`
6062
- Browse files with `ls`, `tree`, and `df`
6163
- Manage files with `mkdir`, `rm`, `rename`, `chmod`, `chown`, and related commands
@@ -77,6 +79,12 @@ put ./dist/app /opt/app/
7779
# upload with parallel workers
7880
put -P 4 ./dist/*.tar.gz /opt/archive/
7981
82+
# sync local -> remote
83+
sync --delete local:./site remote:/var/www/site
84+
85+
# sync remote -> local
86+
sync remote:/var/lib/app local:./backup
87+
8088
# copy between remote hosts
8189
copy @web01:/var/log/app.log @web02:/tmp/
8290
```
@@ -104,6 +112,7 @@ ls list remote directory
104112
lumask set local umask
105113
mkdir create remote directory
106114
put upload from local to remote
115+
sync one-way sync between local and remote paths
107116
pwd print remote working directory
108117
rename rename remote file
109118
rm remove remote file
@@ -118,4 +127,5 @@ bye, exit, quit
118127
### notes
119128
120129
Remote host notation for `copy` uses the `@host:/path` format.
130+
For `sync`, use the `lssync` style `(local|remote):path` prefixes. You can target a specific remote host inside `lsftp` with `remote:@host:/path`.
121131
The default config file path is `~/.lssh.conf`.

0 commit comments

Comments
 (0)