|
1 | | -# tsshd |
| 1 | +## tsshd - tssh server that supports connection migration for roaming |
2 | 2 |
|
3 | 3 | [](https://choosealicense.com/licenses/mit/) |
4 | 4 | [](https://github.com/trzsz/tsshd/releases) |
5 | 5 | [](https://github.com/trzsz/tsshd/blob/main/README.cn.md) |
6 | 6 |
|
7 | | -The `tsshd` works like `mosh-server`, while the [`tssh --udp`](https://github.com/trzsz/trzsz-ssh) works like [`mosh`](https://github.com/mobile-shell/mosh). |
| 7 | +trzsz-ssh ( tssh ) with tsshd supports intermittent connectivity, allows roaming, and can be used on high-latency links such as cellular data connections, unstable Wi-Fi, etc. |
8 | 8 |
|
9 | | -## Advantages |
| 9 | +It aims to provide complete compatibility with openssh, mirroring all its features, while also offering additional useful features not found in the openssh client, plus: |
10 | 10 |
|
11 | | -- Low Latency ( based on [QUIC](https://github.com/quic-go/quic-go) / [KCP](https://github.com/xtaci/kcp-go) ) |
| 11 | +- Keeps the session alive if the client goes to sleep and wakes up later, or temporarily loses its connection. |
12 | 12 |
|
13 | | -- Port Forwarding ( same as openssh, includes ssh agent forwarding and X11 forwarding ) |
| 13 | +- Allows the client to "roam" and change IP addresses, switching between any networks, while keeping alive. |
14 | 14 |
|
15 | | -- Connection Migration ( supports client sleep and wake-up, network switching, reconnection, etc. ) |
| 15 | +### Comparison |
16 | 16 |
|
17 | | -- Proxy Jump ( First hop supports UDP: `Client ---udp--> JumpServer ---tcp--> TargetServer` ) |
| 17 | +tsshd was inspired by [mosh](https://github.com/mobile-shell/mosh), and the `tsshd` works like `mosh-server`, while the `tssh --udp` works like `mosh`. |
18 | 18 |
|
19 | | -## How to use |
| 19 | +| Feature | mosh ( mosh-server ) | tssh ( tsshd ) | |
| 20 | +| ------------------------- | :-----------------------------------------------------------: | :---------------------------------------: | |
| 21 | +| Low Latency | ?? | ✅ [KCP](https://github.com/xtaci/kcp-go) | |
| 22 | +| Keep Alive | ✅ | ✅ | |
| 23 | +| Client Roaming | ✅ | ✅ | |
| 24 | +| Local Echo & Line Editing | ✅ | Not Planned | |
| 25 | +| Multi Platform / Windows | [mosh#293](https://github.com/mobile-shell/mosh/issues/293) | ✅ | |
| 26 | +| SSH X11 Forwarding | [mosh#41](https://github.com/mobile-shell/mosh/issues/41) | ✅ | |
| 27 | +| SSH Agent Forwarding | [mosh#120](https://github.com/mobile-shell/mosh/issues/120) | ✅ | |
| 28 | +| SSH Port Forwarding | [mosh#337](https://github.com/mobile-shell/mosh/issues/337) | ✅ | |
| 29 | +| Output Scrollback | [mosh#122](https://github.com/mobile-shell/mosh/issues/122) | ✅ | |
| 30 | +| OSC52 Sequence | [mosh#637](https://github.com/mobile-shell/mosh/issues/637) | ✅ | |
| 31 | +| tmux -CC Integration | [mosh#1078](https://github.com/mobile-shell/mosh/issues/1078) | ✅ | |
| 32 | +| ProxyJump / ProxyCommand | [mosh#970](https://github.com/mobile-shell/mosh/issues/970) | ✅ First Hop | |
| 33 | + |
| 34 | +tssh and tsshd works exactly like ssh, there are no plans to support local echo and line editing, and will not have the mosh issues: [mosh#1041](https://github.com/mobile-shell/mosh/issues/1041), [mosh#1281](https://github.com/mobile-shell/mosh/issues/1281), [mosh#1295](https://github.com/mobile-shell/mosh/issues/1295), etc. |
| 35 | + |
| 36 | +### How to use |
20 | 37 |
|
21 | 38 | 1. Install [tssh](https://github.com/trzsz/trzsz-ssh) on the client ( the user's machine ). |
22 | 39 |
|
23 | 40 | 2. Install [tsshd](https://github.com/trzsz/tsshd) on the server ( the remote host ). |
24 | 41 |
|
25 | | -3. Use `tssh --udp` to login to the server. Configure as follows to omit `--udp`: |
| 42 | +3. Use `tssh --udp` to login to the server. Or configure as follows in `~/.ssh/config` to omit `--udp`: |
26 | 43 |
|
27 | 44 | ``` |
28 | 45 | Host xxx |
29 | 46 | #!! UdpMode yes |
30 | | - #!! TsshdPath ~/go/bin/tsshd |
31 | | - #!! UdpPort 61000-62000 |
32 | | - #!! UdpAliveTimeout 86400 |
33 | 47 | ``` |
34 | 48 |
|
35 | | -## How it works |
| 49 | +### How it works |
36 | 50 |
|
37 | 51 | - The `tssh` plays the role of `ssh` on the client side, and the `tsshd` plays the role of `sshd` on the server side. |
38 | 52 |
|
39 | 53 | - The `tssh` will first login to the server normally as an ssh client, and then run a new `tsshd` process on the server. |
40 | 54 |
|
41 | | -- The `tsshd` process listens on a random udp port between 61000 and 62000 (can be customized by `UdpPort`), and sends its port number and a secret key back to the `tssh` process over the ssh channel. The ssh connection is then shut down, and the `tssh` process communicates with the `tsshd` process over udp. |
| 55 | +- The `tsshd` process listens on a random udp port between 61001 and 61999 (can be customized by `UdpPort`), and sends its port number and a secret key back to the `tssh` process over the ssh channel. The ssh connection is then shut down, and the `tssh` process communicates with the `tsshd` process over udp. |
42 | 56 |
|
43 | | -- The `tsshd` process will exit if the network is disconnected for more than 24 hours by default, and no longer support reconnection. This can be adjusted by modifying the configuration `UdpAliveTimeout` in seconds. |
| 57 | +### Configurations |
44 | 58 |
|
45 | | -- The `tsshd` supports `QUIC` protocol and `KCP` protocol (the default is `QUIC`), which can be specified on the command line (such as `-oUdpMode=KCP`), or configured as follows: |
| 59 | +``` |
| 60 | +Host xxx |
| 61 | + #!! UdpMode KCP |
| 62 | + #!! UdpPort 61001-61999 |
| 63 | + #!! TsshdPath ~/go/bin/tsshd |
| 64 | + #!! UdpAliveTimeout 86400 |
| 65 | + #!! UdpHeartbeatTimeout 3 |
| 66 | + #!! UdpReconnectTimeout 15 |
| 67 | + #!! ShowNotificationOnTop yes |
| 68 | + #!! ShowFullNotifications yes |
| 69 | +``` |
46 | 70 |
|
47 | | - ``` |
48 | | - Host xxx |
49 | | - #!! UdpMode KCP |
50 | | - ``` |
| 71 | +- `UdpMode`: `No` (the default: tssh works in TCP mode), `Yes` (default protocol: `KCP`), `QUIC` ([QUIC](https://github.com/quic-go/quic-go) protocol), `KCP` ([KCP](https://github.com/xtaci/kcp-go) protocol). |
| 72 | + |
| 73 | +- `UdpPort`: Specifies the range of UDP ports that tsshd listens on, the default value is [61001, 61999]. |
| 74 | + |
| 75 | +- `TsshdPath`: Specifies the path to the tsshd binary on the server, lookup in $PATH if not configured. |
| 76 | + |
| 77 | +- `UdpAliveTimeout`: If the disconnection lasts longer than `UdpAliveTimeout` in seconds, tssh and tsshd will both exit, and no longer support reconnection. The default is 86400 seconds. |
| 78 | + |
| 79 | +- `UdpHeartbeatTimeout`: If the disconnection lasts longer than `UdpHeartbeatTimeout` in seconds, tssh will try to reconnect to the server by a new path. The default is 3 seconds. |
| 80 | + |
| 81 | +- `UdpReconnectTimeout`: If the disconnection lasts longer than `UdpReconnectTimeout` in seconds, tssh will display a notification indicating that the connection has been lost. The default is 15 seconds. |
| 82 | + |
| 83 | +- `ShowNotificationOnTop`: Whether the connection loss notification is displayed on the top. The default is yes, which may overwrite some of the previous output. Set it to `No` to display notifications on the current line of the cursor. |
| 84 | + |
| 85 | +- `ShowFullNotifications`: Whether to display the full notifications or a brief notification. The default is yes, which may output several lines to the screen. Set it to `No` will output only one line. |
51 | 86 |
|
52 | | -## Installation |
| 87 | +### Installation |
53 | 88 |
|
54 | 89 | - Install with apt on Ubuntu |
55 | 90 |
|
@@ -107,7 +142,7 @@ The `tsshd` works like `mosh-server`, while the [`tssh --udp`](https://github.co |
107 | 142 |
|
108 | 143 | </details> |
109 | 144 |
|
110 | | -- Install with [yay](https://github.com/Jguer/yay) on ArchLinux |
| 145 | +- Install with yay on ArchLinux |
111 | 146 |
|
112 | 147 | <details><summary><code>yay -S tsshd</code></summary> |
113 | 148 |
|
@@ -145,10 +180,10 @@ The `tsshd` works like `mosh-server`, while the [`tssh --udp`](https://github.co |
145 | 180 |
|
146 | 181 | - Download from the [GitHub Releases](https://github.com/trzsz/tsshd/releases), unzip and add to `PATH` environment. |
147 | 182 |
|
148 | | -## Contact |
| 183 | +### Contact |
149 | 184 |
|
150 | 185 | Feel free to email the author <lonnywong@qq.com>, or create an [issue](https://github.com/trzsz/tsshd/issues). Welcome to join the QQ group: 318578930. |
151 | 186 |
|
152 | | -## Sponsor |
| 187 | +### Sponsor |
153 | 188 |
|
154 | 189 | [❤️ Sponsor trzsz ❤️](https://github.com/trzsz), buy the author a drink 🍺 ? Thank you for your support! |
0 commit comments