Docs › security
Security
The model
Your Mac runs its own SSH server inside Termfold. It accepts only public key login, never passwords. A phone gets in only if all of this is true:
- its key is in the list of paired phones;
- it is not paused and its access time has not ended;
- the connection comes from a local network address;
- if the phone is set to Ask before each connection, you pressed Allow.
Pairing
- The Mac shows a QR code. It holds a random one time code, the address and the key of this Mac.
- The Mac shows a six digit PIN. It is not in the QR code.
- The phone checks that the Mac has the key from the QR code, then sends the code, the PIN, its name and its public key.
- The Mac accepts if both match, adds the phone and closes the pairing.
The code and PIN last 90 seconds and work once. After five wrong tries the pairing is cancelled. A photo of the QR code alone is not enough: someone must also read the PIN from your Mac screen.
What is protected, and how
| Threat | Protection |
|---|---|
| A fake Mac on the network | After pairing the phone stores the key of your Mac and refuses any other key. |
| Someone on the network trying to connect | Only paired phones are accepted. Connections from outside local network addresses are dropped. |
| Guessing | At most 3 unfinished connections per address, 8 in total and 16 connections overall. An address with 5 failed logins in a minute is blocked for 2 minutes. A login must finish within 20 seconds. |
| A copied QR code | It works once, for 90 seconds, and the PIN is also needed. |
| A phone you stop trusting | Pause, Remove or Quit everywhere close its sessions at once. |
| A phone you trust less | Ask before each connection and a time limit (8 or 24 hours). |
| An unattended phone | Termfold asks for Face ID, fingerprint or the passcode before a terminal opens. |
| A forgotten open session | A session with no typing for the chosen time is closed (default 1 hour). |
| A connection that dropped silently | TCP keepalive notices within about 30 seconds and releases it. |
| Not knowing what happened | The journal records connections and refused attempts, and a notification appears when a phone connects. |
| Programs setting your clipboard | The phone can refuse clipboard writes from the terminal, for each Mac or server. |
| Leaking the environment of the app | The shell starts with a small, clean environment. |
What is not protected
- A paired phone gets a full shell as your Mac user. Termfold does not limit commands. A command filter would not be safe, because any command can start another. For limited access, use a separate Mac user with few rights.
- On the local network Termfold announces the name of your Mac so that phones can find it. The connection itself is encrypted.
- If someone controls your Mac, they control Termfold too.
- The server code has not been audited by an independent party.
Keys
- The Mac key and the phone keys are Ed25519 keys kept in the Keychain of their own device. They are never in iCloud and never leave the device.
- The phone makes a separate key for each Mac it pairs with. Quit everywhere on the phone deletes all of them. Macs paired with an older version keep an older shared key until they are paired again.
What each part can see
- The Mac knows the name, the model, the public key, and the times and addresses of connections of each paired phone.
- The phone knows the address, the user and the public key of each Mac.
- Nothing is sent to any server on the internet.
SSH library
Termfold uses the Apple swift-nio-ssh library on both sides.
Advice
- Keep Allow connections off when you do not need it.
- Use Ask before each connection for borrowed or shared phones.
- Look at Activity now and then.
- If a phone is lost: remove it in the Mac window, then check Activity.