Skip to content

Instantly share code, notes, and snippets.

@josh-padnick
Last active June 15, 2026 00:51
Show Gist options
  • Select an option

  • Save josh-padnick/c90183be3d0e1feb89afd7573505cab3 to your computer and use it in GitHub Desktop.

Select an option

Save josh-padnick/c90183be3d0e1feb89afd7573505cab3 to your computer and use it in GitHub Desktop.
Run ssh-agent via fish shell
#!/bin/bash
#
# Convert ssh-agent output to fish shell
#
eval "$(ssh-agent)" >/dev/null
echo "set SSH_AUTH_SOCK \"$SSH_AUTH_SOCK\"; export SSH_AUTH_SOCK"
echo "set SSH_AGENT_PID \"$SSH_AGENT_PID\"; export SSH_AGENT_PID"
@talbergs

Copy link
Copy Markdown

does anyone know how to unsubscribe from these notifications? Is it life-time?

@Immortalin

Copy link
Copy Markdown

Click unsubscribe at the top of this page or within the email

@jpeeler

jpeeler commented Apr 23, 2026

Copy link
Copy Markdown

For systemd users running a single agent, the modern "proper" way to do this is to launch the ssh-agent user service (in Fedora it's provided by the openssh-clients package). Then all you have to add is:
set -gx SSH_AUTH_SOCK "$XDG_RUNTIME_DIR/ssh-agent.socket"

@duanyrf

duanyrf commented May 11, 2026

Copy link
Copy Markdown

eval (ssh-agent -c)

This works! Thank you!

@xpe

xpe commented Jun 14, 2026

Copy link
Copy Markdown

If you're using macOS, you don't need to manage ssh-agent (whether it be your Fish config or any other shell).

Instead, run this for each key you use to store the passphrase in the Keychain:

ssh-add --apple-use-keychain ~/.ssh/my_key
# This flag works with Apple's `/usr/bin/ssh-add`.
# (Other `ssh` versions may lack the flag.)

Then add this to ~/.ssh/config:

Host *
    UseKeychain yes
    AddKeysToAgent yes

With the above settings:

  • on first use of each key,
  • ssh will look up the passphrase from your Keychain,
  • and load the key into the agent,
  • without prompting you.

You get to avoid the complexities of starting and stopping ssh-agent correctly. No startup code, no stale sockets, no orphaned agent processes.

P.S. This answer matches my experience, and Claude Sonnet 4.6 agrees.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment