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
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: danielrobbins
custom: ["https://paypal.me/breezyops"]
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: |
apt-get update -y
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates make perl jq git gawk sed gzip tar
ca-certificates make perl jq git gawk sed gzip tar openssh-client
rm -rf /var/lib/apt/lists/*
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -35,6 +35,10 @@ jobs:
run: |
make clean
make keychain-$(cat VERSION).tar.gz
- name: Test space-in-home handling
run: |
ver=$(cat VERSION)
./scripts/test-space-home.sh "$ver"
- name: Extract changelog section
run: |
ver=$(cat VERSION)
Expand All @@ -54,4 +58,4 @@ jobs:
.release-notes.md
- name: Summary
run: |
echo 'Artifacts prepared. Use make release or release-refresh locally to publish via API if desired.' >> $GITHUB_STEP_SUMMARY
echo 'Artifacts prepared. Use make release or release-refresh locally to publish via API if desired.' >> $GITHUB_STEP_SUMMARY
79 changes: 71 additions & 8 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,68 @@
# ChangeLog for Keychain - https://github.com/danielrobbins/keychain

## keychain 2.9.7 (31 Oct 2025)

This release fixes critical issues with spaces in HOME directories and usernames, and adds official Git Bash on Windows compatibility.

Bug fixes:

* Fixed keychain failures when HOME directory path contains spaces (e.g., `C:\Users\John Doe`).
([#188](https://github.com/danielrobbins/keychain/issues/188))
* Fixed username detection for usernames containing spaces (e.g., "Mathew Binkley" on Windows).
Implemented portable `get_owner()` function using POSIX-defined `ls -ld` output format with
intelligent field parsing to distinguish space-in-username from normal owner/group fields.
* Fixed pidfile generation to properly quote `SSH_AUTH_SOCK` paths containing spaces while
leaving `SSH_AGENT_PID` unquoted (numeric value). Rewrote `write_pidfile()` to use robust
eval-in-subshell approach for extracting variable values from ssh-agent output.
* All pidfile formats (sh/csh/fish) now correctly handle paths with spaces.
* Fixed ssh-agent invocation to always use `-s` option for Bourne-compatible output, simplifying
pidfile generation and improving compatibility across different environments.
([#185](https://github.com/danielrobbins/keychain/issues/185))

Testing and quality improvements:

* Added `scripts/test-space-home.sh` - automated test harness that simulates HOME directories
with spaces and validates proper handling. Returns proper exit codes for CI integration.
* Integrated space-in-home test into GitHub Actions release workflow to prevent regressions.
* Added ShellCheck disable comments with justification for intentional POSIX ls usage.
* Fixed Unicode arrow characters in comments that caused ShellCheck errors.

New features:

* Added bash completion support (`completions/keychain.bash`) with intelligent context-aware
completion for command-line options, SSH keys, GPG keys, and full `--extended` mode support.
Based on work by @mikkoi with significant enhancements for keychain 2.9.x features:
- Dynamically parses `keychain --help` for up-to-date option completion
- Completes SSH key names from `~/.ssh/*.pub` files
- Completes GPG key IDs (8-character short format)
- `--extended` mode: `sshk:<tab>`, `gpgk:<tab>`, `host:<tab>` with prefix completion
- Detects hostnames from `~/.ssh/config` for `host:` completion
- ShellCheck compliant
([#186](https://github.com/danielrobbins/keychain/issues/186))
* Added Makefile targets: `install-completions` and `uninstall-completions` for optional
bash completion installation (separate from default install target).
* Updated RPM spec file (`keychain.spec.in`) for modern distributions:
- Modernized description to focus on OpenSSH and GnuPG (removed obsolete ssh.com/Sun SSH)
- Updated dependencies: `sh-utils` → `coreutils`, added `Recommends: bash-completion`
- Added bash completion installation to RPM package

Documentation:

* Updated keychain.pod with detailed implementation notes for space handling, POSIX compliance,
and the robust eval approach used in pidfile generation.
* Standardized option ordering in keychain.pod to follow Unix convention (short option first,
then long option), ensuring compatibility with bash completion regex patterns.
* Added comprehensive COMPATIBILITY section to keychain.pod documenting:
- Minimum OpenSSH version (7.3+) and supported features
- GnuPG 2.1+ requirements for gpg-agent integration
- Shell compatibility (Bourne/POSIX, csh/tcsh, fish)
- **Git Bash (MSYS2) for Windows** - officially documented as supported platform
- Legacy SSH implementation status (SunSSH, ssh.com)
- Systemd user environment integration
- Spaces in HOME and paths handling details
* Updated README.md with bash completion installation instructions for both system-wide
and user-only installations.

## keychain 2.9.6 (06 Sep 2025)

Documentation/branding release (no functional code changes):
Expand Down Expand Up @@ -40,7 +103,7 @@ This is a bugfix release.
* Fixed issues with indentation of `note()`, `warn()`, `mesg()`.

* Convert `SSH_AUTH_SOCK in pidfile is invalid; ignoring it` into a debug message,
as this is normal when rebooting your system so is not really useful to show
as this is normal when rebooting your system so is not really useful to show
typically. ([#176](https://github.com/funtoo/keychain/issues/176))

## keychain 2.9.4 (14 May 2025)
Expand Down Expand Up @@ -76,24 +139,24 @@ the following updates:
* Harden keychain so the use of the `--dir` and `--absolute` options cannot be
used to instruct keychain to write pidfiles into insecure areas.
([#174](https://github.com/funtoo/keychain/issues/174))

Prior to this release, it was possible to use these options in combination
with bad (empty) default umask to write pidfiles into a public area on disk
where they were writable by other users. In the worst case, this could allow
arbitrary execution of the contents of the malicious pidfile by keychain.

This hardening now makes it difficult for a user to configure their keychain
in a way that would allow this to happen. Note that if you are not using the
`--dir` or `--absolute` options, keychain will use the `$HOME/.keychain`
directory by default, which is typically under the full control of the
current user and thus not exploitable.
`--dir` or `--absolute` options, keychain will use the `$HOME/.keychain`
directory by default, which is typically under the full control of the
current user and thus not exploitable.

The hardening changes include:

* Setting a global restrictive `umask` in the script.
* Remove pidfiles before redirecting data to them to ensure they are created
with restrictive permissions from the `umask`.
* Check the keychain pidfile directory to ensure it is owned by the current
* Check the keychain pidfile directory to ensure it is owned by the current
user, and only the current user can access it (mode 700). If not, abort
with an informative error message.
* Check any existing pidfiles prior to use to make sure they are owned by the
Expand Down Expand Up @@ -144,7 +207,7 @@ These release notes contain a summary of all changes, including cumulative
changes in pre-releases:

* A new release after 8 years, with Daniel Robbins (script creator) returning as maintainer.
* 60% of the script has been rewritten, and is now compliant with
* 60% of the script has been rewritten, and is now compliant with
[ShellCheck](https://shellcheck.net).
* `--agents` and `--inherit` options have been deprecated to improve ease-of-use.
* `gpg-agent` no longer started by default -- only when a GPG key has been provided on the
Expand Down
7 changes: 3 additions & 4 deletions MAINTAINERS.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Originally authored by Daniel Robbins <drobbins@gentoo.org>
Originally authored by Daniel Robbins <drobbins@breezyops.com>
Maintained August 2002 - April 2003 by Seth Chandler <sethbc@gentoo.org>
Maintained and rewritten April 2004 - July 2007 by Aron Griffis <agriffis@n01se.net>
Maintained July 2009 - Sept 2017 by Daniel Robbins <drobbins@funtoo.org>
Maintained July 2009 - Sept 2017 by Daniel Robbins <drobbins@breezyops.com>
Maintained September 2017 - 2018 by Ryan Harris <x48rph@gmail.com>
Maintained currently by Daniel Robbins <drobbins@funtoo.org>

Maintained currently by Daniel Robbins <drobbins@breezyops.com>
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ V ?= $(shell cat VERSION)
D ?= $(shell date +'%d %b %Y')
Y ?= $(shell date +'%Y')

PREFIX ?= /usr/local
COMPLETIONSDIR ?= $(PREFIX)/share/bash-completion/completions

TARBALL_CONTENTS=keychain README.md ChangeLog.md COPYING.txt MAINTAINERS.txt keychain.pod keychain.1 keychain.spec

all: keychain.1 keychain keychain.spec
Expand All @@ -27,7 +30,7 @@ keychain.1: keychain.pod keychain.sh
pod2man --name=keychain --release=$V \
--center='https://github.com/danielrobbins/keychain' \
keychain.pod keychain.1
sed -i.orig -e "s/^'br/.br/" keychain.1
sed -i.orig -e "s/^'br /.br /" keychain.1

keychain.1.gz: keychain.1
gzip -9 keychain.1
Expand Down Expand Up @@ -85,3 +88,13 @@ release-refresh: $(RELEASE_ASSETS)
echo "GITHUB_TOKEN not set; export a repo-scoped token to proceed." >&2; exit 1; \
fi; \
./scripts/release-orchestrate.sh refresh $(V)

# --- Bash Completion ---
.PHONY: install-completions uninstall-completions

install-completions:
install -d -m 0755 $(DESTDIR)$(COMPLETIONSDIR)
install -m 0644 completions/keychain.bash $(DESTDIR)$(COMPLETIONSDIR)/keychain

uninstall-completions:
rm -f $(DESTDIR)$(COMPLETIONSDIR)/keychain
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Introduction to Keychain
`Keychain` helps you to manage SSH and GPG keys in a convenient and secure
manner. It acts as a frontend to `ssh-agent` and `ssh-add`, but allows you
to easily have one long running `ssh-agent` process per system, rather than
the norm of one `ssh-agent` per login session.
the norm of one `ssh-agent` per login session.

This dramatically reduces the number of times you need to enter your
passphrase. With `keychain`, you only need to enter a passphrase once every
Expand All @@ -16,6 +16,55 @@ allowing your scripts to take advantage of key-based logins.
`Keychain` also integrates with `gpg-agent`, so that GPG keys can be cached
at the same time as SSH keys.

Bash Completion
===============

Keychain includes bash completion support for command-line options, SSH keys,
GPG keys, and the `--extended` key format (`sshk:`, `gpgk:`, `host:`).

Most Linux distributions will install the completion script automatically when
you install keychain via your package manager.

For manual installation:

- **System-wide** (requires `bash-completion` package and root access):
```
sudo make install-completions
```
This installs to `/usr/local/share/bash-completion/completions/` by default.
Use `PREFIX=/usr` for `/usr/share/bash-completion/completions/`.

- **User-only** (no root required):
```
mkdir -p ~/.local/share/bash-completion/completions
cp completions/keychain.bash ~/.local/share/bash-completion/completions/keychain
```

After installation, restart your shell or run:
```
source /etc/bash_completion
```

**Tip:** If pressing tab doesn't show all possible completions when there are
multiple matches (e.g., `sshk:id_<tab>` completes to common prefix but doesn't
list all keys), add this to your `~/.inputrc`:
```
set show-all-if-ambiguous on
```
Then restart your shell or run `bind -f ~/.inputrc`.

Support This Project
====================

Keychain is maintained by [BreezyOps](https://breezyops.com) -
Daniel Robbins' Open Source Innovation Lab. If you find it useful, please consider:

- Starring the repository ⭐
- Joining [Discussions](https://github.com/danielrobbins/keychain/discussions) to share tips and ask questions 💬
- [Supporting development](https://paypal.me/breezyops) to help maintain and improve keychain! ❤️

Your support helps keep this project alive and actively maintained, and supports the creation of future projects. Thank you!

IMPORTANT - GitHub Contributors
===============================

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.9.6
2.9.7
Loading