Private github package to pull with ssh

Hi,
I tried to build my app with EAS (SDK 44), but I don’t achieve to authorize EAS to pull my private github repo which is a javascript package for my app. It builds correctly locally for iOS (eas build -p ios --profile preview --local), but the cloud build has no authorization to read my github repo.

I tried to add my ssh private key to the secret, then to add this eas-pre-install-hook without success:

#!/usr/bin/env bash

mkdir -p ~/.ssh

echo "$PRIVATE_SSH" > ~/.ssh/id_ed25519_eas
chmod 0600 ~/.ssh/id_ed25519_eas

# add your git provider to the list of known hosts
echo "** known_hosts ** "
ssh-keyscan github.com >> ~/.ssh/known_hosts

echo "** ssh-agent ** "
eval $(ssh-agent)
ssh-add ~/.ssh/id_ed25519_eas
ssh-add -l

any idea how to add a ssh key to get access to my private github repo from EAS build ?

Hi @spoutnik97

What you’ve done looks reasonable and similar to the example here:

The first thing that comes to mind (although I doubt it is a problem) is that the example is using a Base64-encoded SSH key and decodes it while writing it to file.

I see you’re using an SSH agent instead of relying on SSH finding your key automatically. I suspect that’s the problem. You’re starting the ssh-agent, but when this shell script exits, the environment variables pointing at the agent disappear and the later invocation of SSH won’t know how to connect to the agent.

So I think you’d have two ways of dealing with this.

  1. Write the key to one of the filenames that SSH tries by default. I suspect if you rename it to ~/.ssh/id_ed25519 (i.e. remove the “_eas” off the end) it will work.
  2. Alternatively, also create a ~/.ssh/config file containing something like this:
Host github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_eas
1 Like

Thanks!
Indeed the config file works well for my needs!

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.