# Terminal with lt

You can leave out the VPS name in the commands below when your Account has one VPS. With
several, `lt` asks which one, or you pass its name or ID, for example `lt term my-vps`.

## lt term

```sh
lt term
```

`lt term` opens your terminal session `main` on the VPS, as the user `dev`, and creates it the
first time. Work in it keeps running when you close the laptop or the connection drops: run
`lt term` again, from this or another computer, and you are back in the same shell with your
programs still running. **Ctrl-b** then **d** leaves it running (**Ctrl-\\** too); `exit` ends
it. The prompt and the terminal title show which session you are in, for example
`[main] dev@my-vps:~$` and `my-vps: main`.

A new session greets you once with its keys. To hide that message, run on the VPS:

```sh
echo 'welcome off' >> ~/.config/liveterminal/term.conf
```

It connects over [Mosh](https://mosh.org) when it can, so what you type appears at once, even on
a slow connection, and the connection survives your laptop sleeping or changing networks. The `lt`
download includes `mosh-client`, installed next to `lt`. When Mosh can't start (for example no
`mosh-client`), `lt term` says why in one line and connects over SSH instead; each key then waits
for a round trip to the VPS. Mosh uses UDP: when nothing comes back over UDP within a few
seconds, `lt term` stops and says so: `Mosh couldn't reach your machine: your network may block
UDP. Use lt term-ssh my-vps instead (same session, over SSH).` The first time, `lt term`
reserves a UDP port for Mosh on the VPS and says so in one line; later sessions reuse it.
`lt term --verbose` shows the details of that step.

Where neither UDP nor SSH gets through (a network that allows only HTTPS), `lt vps connect my-vps`
attaches the same session `main` over HTTPS through the LiveTerminal API, with the same keys;
**Ctrl+]** then **q** also detaches.

On a sleeping VPS, `lt term` (like `lt term-ssh`, `lt vps connect` and `lt vps mosh`) wakes it
first: it prints `Waking my-vps...` and, a few seconds later, how long the wake took, then
connects with your programs still running. **Ctrl-C** stops waiting (the VPS goes on waking).
Waking is a start, so it needs permission to start the VPS. A stopped VPS is not booted for you:
start it with `lt vps start my-vps`.

### Terminal sessions

```sh
lt term --session build
lt term --no-session
```

`--session <name>` attaches another session instead, created if needed. `--no-session` opens a
plain login shell, like `ssh`, for scripts: `exit` or a dropped connection ends it.

- Sessions your AI starts (over MCP) are on the same list: **Ctrl-b** then **s** switches to
  one, or `lt term --session <name>` opens it.
- On the VPS, `ds NAME`, `dsn`, `dl`, `dk NAME` and `dn`/`dp`/`dg NAME` work on the same sessions.

Inside a session you have tmux's keys: press **Ctrl-b**, then

| Key          | What it does                                            |
| ------------ | ------------------------------------------------------- |
| **d**        | detach; the session keeps running                       |
| **s**        | pick a session from a list (arrows, Enter; Esc cancels) |
| **c**        | start a new session in the same folder and switch to it |
| **n**, **p** | go to the next or previous session                      |
| **$**        | rename this session                                     |
| **x**        | end this session (it asks y/n first)                    |
| **?**        | show these keys                                         |
| **Ctrl-b**   | send Ctrl-b itself to the program                       |

The list, the questions and the help show only in your terminal, never in the session itself.
To use another prefix, for example Ctrl-a, run `export LT_TERM_PREFIX=C-a` before `lt term`, or
put the line `prefix C-a` in `~/.config/liveterminal/term.conf` on the VPS (`none` turns the
keys off). For split panes, run tmux inside a session.

## lt term-ssh

```sh
lt term-ssh
lt term-ssh --session build
```

The same over SSH, for networks that block the UDP traffic Mosh uses. The session keys work
here too.

## Mosh license

`mosh-client` is [Mosh](https://mosh.org) 1.4.0, free software under the GNU GPL version 3. The
`lt` download includes its license and the exact sources it was built from; `lt` itself is a
separate program that runs it and is not covered by the GPL.

## Plain ssh

`lt ssh-config` writes an SSH alias for each of your VPSs, so `ssh` and the tools built on it
(`scp`, `rsync`, VS Code Remote) work:

```sh
lt ssh-config
ssh my-vps.lt.internal
```

Run `lt ssh-config` again after you create or rename a VPS.

Without the CLI, see [SSH and IDEs](/ssh/).

Next: [sign in your agents](/agent-login/).