# 2-step guide for github repos with Pkg

**URL:** <https://discourse.julialang.org/t/2-step-guide-for-github-repos-with-pkg/50166>\
**Category:** New to Julia\
**Tags:** package, github, ssh\
**Created:** [November 15, 2020, 12:48am UTC](https://discourse.julialang.org/t/2-step-guide-for-github-repos-with-pkg/50166 "2020-11-15T00:48:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [November 15, 2020, 12:48am UTC](https://discourse.julialang.org/t/2-step-guide-for-github-repos-with-pkg/50166/1 "2020-11-15T00:48:37Z")

</div>

### 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](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account)

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

run the [following two lines](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) (in order):

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

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

[copy the following](https://stackoverflow.com/a/18915067/1798351) into your `~/.bashrc`, then restart:

```julia-auto
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

```

---

<div class="post-metadata">

**Author:** ![soylentgreeen202](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@soylentgreeen202](https://discourse.julialang.org/u/soylentgreeen202)\
**Post date:** [February 18, 2021, 8:35pm UTC](https://discourse.julialang.org/t/2-step-guide-for-github-repos-with-pkg/50166/2 "2021-02-18T20:35:50Z")

</div>

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 ☹. So I read up more on ssh-agent end ended up [here](https://wiki.archlinux.org/index.php/SSH_keys#ssh-agent_as_a_wrapper_program). 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.
