Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot clone private repository from github #12545

Closed
juliusoh opened this issue Jul 28, 2023 · 2 comments
Closed

Cannot clone private repository from github #12545

juliusoh opened this issue Jul 28, 2023 · 2 comments
Labels

Comments

@juliusoh
Copy link

I have a packer script:

build {
  sources = ["source.amazon-ebs.devbox"]

  provisioner "file" {
    source      = "./ssh/"
    destination = "/home/ubuntu/.ssh/"
  }

  provisioner "shell" {
    inline = [
      "chmod 600 /home/ubuntu/.ssh/kubernetes-cluster-provision-devbox",
      "chmod 644 /home/ubuntu/.ssh/kubernetes-cluster-provision-devbox.pub",
      "chmod 600 /home/ubuntu/.ssh/config"
    ]
  }

  provisioner "shell" {
    script = "./packer-files/bootstrap.sh"
  }
}

The bootstrap is running this file:

echo "ls"
ls -a ~/.ssh
# Clone the repository
echo "Cloning the repository"
ssh-keyscan github.companyname.net >> ~/.ssh/known_hosts
eval ssh-agent
ssh-add ~/.ssh/test
git clone git@test:test2/test3.git

Currently getting

==> amazon-ebs.devbox: Load key "/home/ubuntu/.ssh/keyname": error in libcrypto
==> amazon-ebs.devbox: git@github.companymae.net: Permission denied (publickey).
==> amazon-ebs.devbox: fatal: Could not read from remote repository.

@juliusoh juliusoh added the bug label Jul 28, 2023
@nywilken
Copy link
Contributor

nywilken commented Oct 5, 2023

Hi @juliusoh this looks like an issue with the ssh key not being loaded properly. Please validate that the is formatted properly and loaded it properly.

If you are still running into issues you can use troubleshoot this issue further by adding a breakpoint provisioner to the template, which will pause the build so that you can try connecting manually.

build {
  sources = ["source.amazon-ebs.devbox"]

  provisioner "file" {
    source      = "./ssh/"
    destination = "/home/ubuntu/.ssh/"
  }

  provisioner "shell" {
    inline = [
      "chmod 600 /home/ubuntu/.ssh/kubernetes-cluster-provision-devbox",
      "chmod 644 /home/ubuntu/.ssh/kubernetes-cluster-provision-devbox.pub",
      "chmod 600 /home/ubuntu/.ssh/config"
    ]
  }

  provisioner "breakpoint" {}

  provisioner "shell" {
    script = "./packer-files/bootstrap.sh"
  }
}

You can also run Packer build with the debug flag packer build -debug template.pkr.hcl to steps through the build process. This will output the ssh key created by Packer.

Since this doesn't appear to be an issue with Packer I'm going to close this issue and recommend you reach out to the community forum for help. The GitHub issue tracker is only watched by a small subset of maintainers and is really reserved for bugs rather than questions. You'll have a better chance of finding someone who can help you in the forum.

@nywilken nywilken closed this as completed Oct 5, 2023
Copy link

github-actions bot commented Nov 5, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants