Cloning a git repo in a vm via ssh

Viewed 65

I am running a script in the ubuntu vm and I am trying to clone from my private repo.

I added keygen in my script for ssh clone but I get an error. This is what my script looks like and the error

echo ">> Checking out $GITHUB_PAGES_BRANCH branch from $GITHUB_PAGES_REPO"
cd /tmp/helm/publish
mkdir -p "$HOME/.ssh"
ssh-keyscan -H github.com >> "$HOME/.ssh/known_hosts"
echo "CLONING:::::"
git clone -b "$GITHUB_PAGES_BRANCH" "git@github.com:$GITHUB_PAGES_REPO.git" .
echo "CLONED :::::"
ls

I get this error in my console

>> Checking out test-branch branch from getME/demo
# github.com:22 SSH-2.0-babeld-cXXXXX
# github.com:22 SSH-2.0-babeld-cXXXXX
# github.com:22 SSH-2.0-babeld-cXXXXX
# github.com:22 SSH-2.0-babeld-cXXXXX
# github.com:22 SSH-2.0-babeld-cXXXXX

CLONING:::::
Cloning into '.'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

CLONED :::::

I am running this script on Github Actions.

Any help is appreciated.

1 Answers

Trying a git clone -c core.sshCommand='ssh -Tv' clone -b "$GITHUB_PAGES_BRANCH" "git@github.com:$GITHUB_PAGES_REPO.git" would hep seeing what is going on.

See this action as an example of an actual SSH clone working

        run: |
          mkdir -p ~/.ssh/
          echo "$GIT_SSH_RSA_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          ssh-keyscan github.com >> ~/.ssh/known_hosts

The chmod is important.

Related