Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ On Windows and Linux, use `--config FILE` to select another file; command-line v
- When `agent.upstream` is empty, `UPSTREAM_SSH_AUTH_SOCK` takes precedence over `SSH_AUTH_SOCK`. If neither is set, the GUI uses the native OpenSSH agent endpoint: `\\.\pipe\openssh-ssh-agent` on Windows and `~/.ssh/ssh-agent.sock` on macOS and Linux.
- To keep the upstream endpoint tied to a changing environment variable, set `agent.upstream = "env:SSH_AUTH_SOCK"`, or choose Environment variable in GUI Settings and enter its name. The GUI resolves this reference at startup and when Settings are applied, while saving the `env:NAME` reference in the config file. The variable must be set and non-empty.
- Environment variables in ordinary paths and a leading `~` are expanded using the GUI process environment.
- `[history].path` selects the selection-history database when set. If omitted or empty, the GUI uses `history.sqlite` in the application data folder; relative paths are resolved from that folder. GUI Settings leaves the field blank and shows the resolved default path as its placeholder. It saves `history.path` only when you enter or choose a path.
- `[history].enabled` controls whether the GUI records and shows selection history. `[history].remember_selection` controls whether it remembers the last selected key for each verified target host. Both default to `true`, can be changed in GUI Settings, and are written to the config only when set to `false`. When both are `false`, the GUI does not create or open the SQLite database.
- If the configured Listen endpoint is active or blocked by a non-socket file, the GUI starts with the proxy `Not configured`. A stale socket owned by the current user is replaced when KeySelect confirms that it is no longer listening.

The configuration loader rejects unknown keys. Logging is off by default. Set `log.level` to enable it and optionally set `log.file` to append logs to a file. When `log.file` is empty, logs go to standard error.
Expand All @@ -385,6 +387,12 @@ banner exchange: Connection to <IP> port <Port>: Software caused connection abor
Example configuration for `Git Bash` on Windows, using a Cygwin-compatible listener:

```toml
[history]
# Add a setting only to override its default:
# enabled = false
# path = "/path/to/history.sqlite"
# remember_selection = false

[agent]
# Replace USERNAME with your Windows user name:
upstream = 'C:\Users\USERNAME\.ssh\ssh-upstream-agent.sock'
Expand Down Expand Up @@ -421,6 +429,10 @@ The GUI has an Auto Select switch beside Agent Proxy. Enabling it requires confi

The window title combines the action, application name, and local display time. The request-context area begins with the same timestamp followed by host details. It lets you scroll to earlier hops. Use the arrow keys to move through matches, Enter to select, and Esc to cancel.

When `history.remember_selection` is enabled and the request includes a verified target host key, the GUI remembers the selected key for that host and preselects it the next time the same host key is seen. The picker still opens and requires you to confirm a selection. Requests without a verified target host key start with the first key.

When `history.enabled` is enabled, choose `File > History…` or press Ctrl+Shift+H (Cmd+Shift+H on macOS) to review request time, target host and forwarded hops, selected key, selection time, and whether the picker completed, was canceled, or timed out. Right-click a row to copy its displayed information or delete it. Use `Export CSV` to save the full history and host paths. The result describes the picker interaction; it does not indicate whether the SSH server accepted authentication.

Right-click a key row and choose `Copy`, or press Ctrl+C, to copy its Comment, Type, Size, and Fingerprint as tab-separated text.

## Shared behavior
Expand Down Expand Up @@ -501,7 +513,7 @@ SSH KeySelect has no telemetry, analytics, automatic update checks, or diagnosti

The proxy communicates with SSH clients and the upstream agent configured through its endpoints. SSH clients receive public key identities and permitted authentication signatures. With SSH agent forwarding, remote processes can receive these responses through your SSH connection. Private key material stays in the upstream agent and is never received by KeySelect. See [Security and limitations](#security-and-limitations) and the [agent forwarding guidance](#through-agent-forwarding).

The GUI stores configuration locally when you save it. The pickers can read local `known_hosts` files to display host-name hints.
The GUI stores configuration locally. When History is enabled, it stores verified target-host and forwarding-hop key fingerprints, `known_hosts` display hints, the selected public-key data, fingerprint and comment, and local request and selection times. When key remembrance is enabled, it also stores target-host and selected-key fingerprints to restore the prior choice. Public-key data does not include private keys. Host names shown in history are local `known_hosts` hints, not verified host names.

Diagnostic logging is off by default. When enabled, logs go to local output or the CLI log file you specify and can contain endpoint paths, host key fingerprints, and request metadata. Review logs before sharing them. Bundled libraries do not add third-party online services to the application. Your upstream agent and SSH client have their own settings and privacy policies.

Expand Down
47 changes: 42 additions & 5 deletions cmd/ssh-keyselect-gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/jfut/ssh-keyselect/internal/config"
"github.com/jfut/ssh-keyselect/internal/guitable"
"github.com/jfut/ssh-keyselect/internal/identity"
"github.com/jfut/ssh-keyselect/internal/selectionhistory"
"github.com/jfut/ssh-keyselect/internal/selector"
"github.com/jfut/ssh-keyselect/internal/transport"
"github.com/jfut/ssh-keyselect/internal/upstream"
Expand All @@ -48,8 +49,15 @@ type guiApp struct {
endpointAgent *guiEndpointAgent
server *agentproxy.Server
selector *selector.GUISelector
historyStore *selectionhistory.Store
historyStores []*selectionhistory.Store
historyPath string
historyError string
userDataPath string
runtime *guiRuntime
window *mygo.Window
historyWindow *mygo.Window
historyView *guiHistoryState
mainWindow atomic.Pointer[mygo.Window]
mainVisible atomic.Bool
tray *mygo.Tray
Expand Down Expand Up @@ -230,9 +238,28 @@ func executeGUI(args []string, stdout, stderr io.Writer) int {

mygo.App.SetName("SSH KeySelect")
mygo.App.SetVersion(version)
if err := setGUIUserDataPath(); err != nil {
userDataPath, err := setGUIUserDataPath()
if err != nil {
return cmdutil.ReportError(stderr, guiCommandName, err)
}
app.userDataPath = userDataPath
if cfg.History.Enabled || cfg.History.RememberSelection {
historyPath, pathErr := guiHistoryDatabasePath(userDataPath, cfg.History.Path)
if pathErr != nil {
app.historyError = pathErr.Error()
logger.Warn("could not resolve GUI selection data path", "error", pathErr)
} else {
app.historyPath = historyPath
historyStore, openErr := selectionhistory.Open(historyPath)
if openErr != nil {
app.historyError = openErr.Error()
logger.Warn("could not open GUI selection data", "error", openErr)
} else {
app.historyStore = historyStore
}
}
}
guiSelector.SetHistoryOptions(app.historyStore, cfg.History.Enabled, cfg.History.RememberSelection)
mygo.Theme.SetSource(mygo.ThemeSource(cfg.GUI.Theme))
// Keep the native application menu on macOS; other platforms use the
// in-window menu bar so its text follows the app's normal UI size.
Expand All @@ -255,17 +282,17 @@ func executeGUI(args []string, stdout, stderr io.Writer) int {
}

// setGUIUserDataPath keeps MyGo's per-user files alongside ssh-keyselect config.
func setGUIUserDataPath() error {
func setGUIUserDataPath() (string, error) {
base, err := os.UserConfigDir()
if err != nil {
return fmt.Errorf("locate user data directory: %w", err)
return "", fmt.Errorf("locate user data directory: %w", err)
}
path := filepath.Join(base, "ssh-keyselect")
if err := os.MkdirAll(path, 0o700); err != nil {
return fmt.Errorf("create user data directory: %w", err)
return "", fmt.Errorf("create user data directory: %w", err)
}
mygo.App.SetPath(mygo.PathUserData, path)
return nil
return path, nil
}

func (a *guiApp) shutdown() {
Expand All @@ -275,6 +302,16 @@ func (a *guiApp) shutdown() {
if a.runtime != nil {
a.runtime.Close()
}
if a.historyWindow != nil && !a.historyWindow.IsDestroyed() {
a.historyWindow.Close()
}
for _, store := range append(a.historyStores, a.historyStore) {
if store != nil {
if err := store.Close(); err != nil {
a.logger.Warn("close GUI selection history", "error", err)
}
}
}
if a.tray != nil {
a.tray.Destroy()
}
Expand Down
Loading
Loading