# Koshi 0.6.0 — Sharing with other users (/docs/v0.6/using/other-users)



Your sessions are yours alone unless you say otherwise. No other user of this
machine can see them or reach them.

This works on Linux and macOS. On Windows koshi reads `allow-other-users` and
`shared-sessions-dir` without an error and does nothing with them, and
`--allow-other-users` is refused.

This is about the other users of **this** machine. Reaching a session from
another machine is [remote access](/docs/v0.6/remote), and neither key turns
the other on.

## Turn it on [#turn-it-on]

```kdl title="koshi.kdl"
version 2
allow-other-users #true
```

**Both files have to say so.** Your `koshi.kdl` opens your sessions to other
users. Their own `koshi.kdl` makes their `koshi` look for sessions that are not
theirs. A user who leaves it off sees only their own sessions, whatever your
file says.

Turn it on for a machine several people share on purpose — a build box, a lab
machine, a pair-programming host. Leave it off on a laptop.

<Callout type="warn">
  The programs inside a session keep running as the user who started it, whoever
  attaches. Attaching never hands anyone your account; it hands them a view of,
  and typing into, panes that still run as you.
</Callout>

## When the setting takes effect [#when-the-setting-takes-effect]

The session reads `koshi.kdl` again for every connection and every request
another user makes, so **turning it off shuts those users out without a
restart**: a new connection is refused, and a terminal already attached is
dropped the next time it types.

Every `koshi` command reads the file again as it runs, so a listing shows what
your file says at that moment.

Turning it **on** reaches the sessions you start after the change. A running
session keeps the socket it already has until it restarts. `koshi update`
restarts every session it finds, and a restarted session reads this key again
and binds where your file says at that moment.

## One session, for its whole life [#one-session-for-its-whole-life]

```bash
koshi --headless --allow-other-users
```

That session serves the other users of this machine for its whole life,
whatever `koshi.kdl` says. It never reads the key.

`--allow-other-users` goes only with `--headless`.

## Where the sockets live [#where-the-sockets-live]

```kdl title="koshi.kdl"
version 2
shared-sessions-dir "/var/run/koshi"
```

Set it to a directory every user who shares the machine can enter. Leave it out
and koshi uses `/tmp/koshi`.

**Every user who shares the machine has to name the same directory.** A user
whose file names a different one looks in that one and finds nobody.

This only says where the sockets go. Nobody else reaches them until
`allow-other-users` is on.

## Naming another user's session [#naming-another-users-session]

`koshi list-sessions` names another user's session in its `owner` column, such
as `1001`. Name such a session as `<user id>/<session id>`:

```bash
koshi attach 1001/session-3f2a…
```

koshi then looks only in the folders of the shared directory that user owns.
When two users' sockets advertise the same session id, the bare id reaches
neither, and the refusal names the owner form to use.

## Your own sessions [#your-own-sessions]

Sessions that are not shared are advertised in one directory per user:

| Platform     | Directory                                   |
| ------------ | ------------------------------------------- |
| Linux, macOS | `/tmp/koshi-<your user id>`                 |
| Windows      | `run` under your application data directory |

On Linux and macOS the name is built from your user id and nothing else, so
every shell you open finds the same sessions.

`KOSHI_RUNTIME_DIR` names another directory, and koshi reads it only when it
holds an absolute path. A relative value is ignored.

<Callout type="warn">
  Two koshi processes holding different `KOSHI_RUNTIME_DIR` values use different
  directories and do not find each other.
</Callout>

## Check it [#check-it]

```bash
koshi doctor
```

The `session directory` row names where sessions are advertised and who may
reach that directory. The `runtime directory` row names the directory in use
and the rule that produced it.

```text
runtime directory   ok  /tmp/koshi-1000 is ready; koshi names it after your user id
session directory   ok  sessions are advertised in /tmp/koshi-1000 (mode 700), which only you may reach
```
