2-step guide for github repos with Pkg

Sufficient conditions for 1 and 2 to “just work”

  1. you are using some version of linux
  2. you ran ssh-keygen and hit enter until the prompts stopped
    1. ensure that ~/.ssh/id_rsa exists afterward
  3. you have followed these instructions for key exchange with github

1. Single session (interactive, works until you reboot):

run the following two lines (in order):

  1. eval "$(ssh-agent -s)"
  2. ssh-add ~/.ssh/id_rsa

2. Every session (non-interactive, runs at boot):

copy the following into your ~/.bashrc, then restart:

SSH_ENV="$HOME/.ssh/agent-environment"

function start_agent {
    echo "Initialising new SSH agent..."
    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo succeeded
    chmod 600 "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
    /usr/bin/ssh-add;
}

# Source SSH settings, if applicable

if [ -f "${SSH_ENV}" ]; then
    . "${SSH_ENV}" > /dev/null
    #ps ${SSH_AGENT_PID} doesn't work under cywgin
    ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
        start_agent;
    }
else
    start_agent;
fi
5 Likes

I use julia with nvim-qt and vimcmdline and somewhere in this chain julia wasn’t grabbing the relevant environment variables, requiring me to set them manually each session :frowning:. So I read up more on ssh-agent end ended up here. The systemd approach didn’t work for me but prefixing startx with ssh-agent in ~/.bash_profile did the trick.

I’m inexperienced in this territory, but as I understand things now one needs

  1. ssh-agent configured AND running
  2. SSH_AUTH_SOCK and SSH_AGENT_PID environment variables set to values that reflect this running instance of ssh-agent

There seems to be diverse ways to meet these prerequisites from what I’ve seen skimming these discourse and arch wiki links. I’m still very unsure how they compare to one another, but this ssh-agent startx business works in my case so I’m sticking with that as I continue to learn more about how my personal system works.