Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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"
@NeMO84

This comment has been minimized.

Copy link

@NeMO84 NeMO84 commented Jun 13, 2017

Thanks! Came in very handy.

@Optiligence

This comment has been minimized.

Copy link

@Optiligence Optiligence commented Apr 24, 2018

eval (ssh-agent -c)

@ivakyb

This comment has been minimized.

Copy link

@ivakyb ivakyb commented Mar 4, 2019

Consider to use

fish_ssh_agent

Utility functions to start your ssh agent when using fish shell. You will only need to run ssh-add and type your password once, after the running ssh_agent should do the work for you. Need to run once, environment variables shared between sessions.

@talbergs

This comment has been minimized.

Copy link

@talbergs talbergs commented Oct 3, 2019

# config.fish
if test -z (pgrep ssh-agent)
  eval (ssh-agent -c)
  set -Ux SSH_AUTH_SOCK $SSH_AUTH_SOCK
  set -Ux SSH_AGENT_PID $SSH_AGENT_PID
  set -Ux SSH_AUTH_SOCK $SSH_AUTH_SOCK
end
@timmyjose

This comment has been minimized.

Copy link

@timmyjose timmyjose commented Dec 14, 2019

# config.fish
if test -z (pgrep ssh-agent)
  eval (ssh-agent -c)
  set -Ux SSH_AUTH_SOCK $SSH_AUTH_SOCK
  set -Ux SSH_AGENT_PID $SSH_AGENT_PID
  set -Ux SSH_AUTH_SOCK $SSH_AUTH_SOCK
end

Excellent. Thank you!

@aadibajpai

This comment has been minimized.

Copy link

@aadibajpai aadibajpai commented Jun 15, 2020

# config.fish
if test -z (pgrep ssh-agent)
  eval (ssh-agent -c)
  set -Ux SSH_AUTH_SOCK $SSH_AUTH_SOCK
  set -Ux SSH_AGENT_PID $SSH_AGENT_PID
  set -Ux SSH_AUTH_SOCK $SSH_AUTH_SOCK
end

is it worth it adding ssh-add somewhere in here so you only need to input your passphrase once per session?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.