Skip to content

Commit dc24a78

Browse files
taylaandclaude
andcommitted
docs: add SSH prerequisite and platform caveats for cross-machine sync
fix: check remote DB has sessions table, not just file exists Setup guide now documents: - Passwordless SSH as a prerequisite with setup instructions - Platform limitation: Windows/WSL and Docker not supported - Requires native Unix/Linux SSH server with sqlite3 Fix: _remote_db_exists() now verifies the sessions table exists, not just the file. Prevents false positive when an empty or wrong-schema DB file exists on the remote (e.g. created by a previous failed scp or sqlite3 auto-create). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 88d2b1c commit dc24a78

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

‎docs/setup-guide.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,36 @@ All configuration lives in a single file: `~/.config/studyctl/config.yaml`. This
8787

8888
### Hosts — Cross-Machine Sync
8989

90+
#### Prerequisites: Passwordless SSH
91+
92+
Cross-machine sync uses SSH and rsync under the hood. **Passwordless SSH must be configured** between all machines before sync will work. If you're prompted for a password, sync will hang or fail.
93+
94+
Set up SSH key-based auth between each pair of machines:
95+
96+
```bash
97+
# 1. Generate a key (if you don't have one)
98+
ssh-keygen -t ed25519 -C "your-email@example.com"
99+
100+
# 2. Copy your public key to each remote machine
101+
ssh-copy-id ataylor@192.168.125.22 # macmini
102+
ssh-copy-id ataylor@192.168.125.21 # macbookpro
103+
104+
# 3. Verify passwordless login works
105+
ssh ataylor@192.168.125.22 "echo ok" # should print "ok" with no password prompt
106+
```
107+
108+
Do this from **every machine** to **every other machine** you want to sync with. If machine A syncs with B and C, then A needs key access to B and C, B needs access to A and C, etc.
109+
110+
> **Platform limitation:** Cross-machine sync requires a native Unix/Linux SSH server on the remote host with direct access to the filesystem. This means sync **does not work** with:
111+
>
112+
> - **Windows hosts running WSL** — SSH connects to Windows, not the WSL filesystem where the database lives. The `$HOME` path and `sqlite3` binary won't resolve correctly.
113+
> - **Docker containers** — unless SSH is exposed from the container (not recommended). The database path inside the container differs from the host path.
114+
> - **Network-attached storage** — the remote needs `sqlite3` installed and SSH access.
115+
>
116+
> Supported targets: macOS, native Linux, any Unix system with SSH + sqlite3.
117+
118+
#### Host Configuration
119+
90120
The `hosts` section defines all your machines. The local machine is auto-detected by matching your system hostname, and everything else becomes a sync target.
91121

92122
```yaml

‎packages/agent-session-tools/src/agent_session_tools/sync.py‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,24 @@ def _quote_remote_path(path: str) -> str:
152152

153153

154154
def _remote_db_exists(host: str, db_path: str) -> bool:
155-
"""Check if a database file exists on the remote host."""
155+
"""Check if a usable database exists on the remote host.
156+
157+
Verifies both that the file exists AND contains the sessions table.
158+
An empty file or wrong-schema DB returns False.
159+
"""
156160
_ensure_mux_dir()
157161
remote_path = _quote_remote_path(db_path)
162+
# Check file exists AND has the sessions table
158163
result = subprocess.run(
159-
["ssh", *_SSH_MUX_OPTS, host, f"test -f {remote_path}"],
164+
[
165+
"ssh",
166+
*_SSH_MUX_OPTS,
167+
host,
168+
f"test -f {remote_path} && sqlite3 {remote_path} "
169+
f"{shlex.quote('SELECT COUNT(*) FROM sessions LIMIT 1')}",
170+
],
160171
capture_output=True,
172+
text=True,
161173
)
162174
return result.returncode == 0
163175

0 commit comments

Comments
 (0)