API reference

Key classes and methods for contributors and developers.

Authentication flow

  1. The user enters username + password in the login window.
  2. UserManager.authenticate(username, password) compares the hash, derives the session key on success, and returns it.
  3. The session key is passed into UserConnectionManager and kept only in that instance.
  4. When a connection is read, the encrypted password is decrypted with the session key.
  5. On logout: UserConnectionManager.dispose() removes the key from RAM.

Mount / unmount flow

  1. The UI calls SSHFSController.mount(connection) in a worker thread.
  2. For auth_method="ask": password modal; otherwise connection.password or connection.key_path.
  3. The argument list is built and sshfs.exe is started as a detached subprocess.
  4. After 3 s, list_mounts() validates whether the drive is available.
  5. The UI receives a mount_state_changed(connection_id, "mounted"|"failed", error_text) signal.
  6. Unmount: SSHFSController.unmount(letter) with the fallback chain.

CLI IPC flow

┌────────────┐   JSON-Request    ┌──────────────┐
│ cli_main.py│ ─────────────────►│  ipc_server  │
│  (CLI EXE) │                   │  (GUI Thread)│
└────────────┘ ◄───── JSON ──────└──────────────┘
                Credentials             │
       ▼                                ▼
   spawn ssh                     UserConnMgr.lookup(key)
                                        │
                                        ▼
                                 SQLite + Decrypt

Pipe protocol

// Request
{
  "op": "connect",
  "key": "<access_key>",
  "exec": "<optional command>"
}

// Response (success)
{
  "ok": true,
  "host": "...",
  "port": 22,
  "user": "...",
  "auth_method": "password" | "key",
  "password": "...",
  "key_path": "...",
  "exec": "..."
}

// Response (error)
{ "ok": false, "error": "invalid_key" | "no_session" | "cli_disabled" }

Settings flow

  1. The settings dialog modifies the AppSettings instance.
  2. AppSettings.save() writes JSON.
  3. The settings_changed signal is emitted.
  4. Theme: QApplication.setStyleSheet(load_theme(name)) — no restart needed.
  5. Language: i18n.set_locale(code); all widgets re-render through retranslate_ui().

Public classes & methods

config.AppSettings

Method Description
AppSettings.load() → AppSettingsReads config.json, merges it with defaults, and returns an instance.
save() → NoneWrites current values as JSON.
reset_to_defaults() → NoneResets everything to defaults and persists it.

auth_manager.UserManager

Method Description
create_user(username, password) → UserCreates a new user and hashes the password.
authenticate(username, password) → SessionKey | NoneLogin. Returns the derived session key on success.
change_password(user_id, old, new) → boolRe-encrypts all connection passwords with the new session key.
delete_user(user_id) → NoneCascade-deletes connections.

auth_manager.UserConnectionManager

Method Description
list() → list[Connection]All connections for the current user.
get(id) → ConnectionOne connection — password decrypted.
create(connection) → intCreates and persists the encrypted password. Returns the ID.
update(connection) → NoneRe-encrypt &amp; persist.
delete(id) → NoneDelete.
by_access_key(key) → Connection | NoneUsed by the IPC server for CLI lookup.

sshfs_controller.SSHFSController

Method Description
mount(connection, password=None) → MountResultStarts a mount. Returns status plus stderr if present.
unmount(letter) → boolUnmounts cleanly, with fallback strategies.
list_mounts() → list[MountInfo]Current mounts.
status_for(connection) → str"mounted" / "unmounted" / "stale".
cleanup_stale() → intCleans up stale mount points.

single_instance.SingleInstance

with SingleInstance("SSHWinManager_Mutex_v1") as inst:
    if not inst.acquired:
        inst.activate_existing_window()
        sys.exit(0)
    run_app()

Generated API docs (optional)

Option A — pdoc

pip install pdoc
pdoc -o site/api src/

Option B — MkDocs Material + mkdocstrings

pip install mkdocs-material mkdocstrings[python]
mkdocs serve