In a github action I'm building an Elixir project which has a dependency on a private github repo i.e. during the deps.get phase it clones it using git. The problem is that the ssh connection to github fails with "Host key verification failed.
Below is the github action step code for getting the dependencies, with the difference that instead of calling mix deps.get
, as I normally would, I'm just doing a ssh just to test the connection:
mkdir -p ~/.ssh
echo $EB_COMMON_ACCESS_KEY >> ~/.ssh/github_identity.pem
echo "Host github.com" >> ~/.ssh/config/config
echo " IdentityFile ~/.ssh/github_identity.pem" >> ~/.ssh/config
# echo " StrictHostKeyChecking no" >> ~/.ssh/config
ssh-keyscan -H github.com > ~/.ssh/known_hosts
chmod 600 ~/.ssh/github_identity.pem
echo try ssh
ssh git@github.com ls /
The output of this is:
try ssh
Host key verification failed.
Doing the same steps in a docker container instantiated from the same image as the one used for running the github action works fine.
Also, I tried with and without the echo " StrictHostKeyChecking no" >> ~/.ssh/config
without success.
Anybody has suggestions for this?
Doing ssh -v git@github.com
helped me understand what ssh is actually trying to do.
The problem is that github action runs as root
user but ~/.ssh
expands to /github/home/.ssh
while ssh was looking for the configuration files in /root/.ssh
or in /etc/ssh
Once I put the configuration in the right place everything went fine