Failed to pull GitHub private repo

I know this has been asked before - but I absolutely don't get how to solve it from the responds. I got the SSH key from SSH keys settings, pasted it to my SSH keys on GitHub. I use the Devcontainer template, with my own repository URL. I keep getting an error:
envbuilder v1.1.0+a3a6a83 - Build development environments from repositories in a container
#1: ๐Ÿ“ฆ Cloning [email protected]:MyUsername/my-repository.git to /workspaces/my-repository...
#1: ๐Ÿ”‘ Using SSH authentication!
#1: ๐Ÿ”‘ No SSH key found, falling back to agent!
#1: โŒ Failed to connect to SSH agent: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
#1: Parsed Git URL as "ssh://[email protected]/MyUsername/my-repository.git"
Failed to clone repository: clone "[email protected]:MyUsername/my-repository.git": error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
Falling back to the default image...
envbuilder v1.1.0+a3a6a83 - Build development environments from repositories in a container
#1: ๐Ÿ“ฆ Cloning [email protected]:MyUsername/my-repository.git to /workspaces/my-repository...
#1: ๐Ÿ”‘ Using SSH authentication!
#1: ๐Ÿ”‘ No SSH key found, falling back to agent!
#1: โŒ Failed to connect to SSH agent: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
#1: Parsed Git URL as "ssh://[email protected]/MyUsername/my-repository.git"
Failed to clone repository: clone "[email protected]:MyUsername/my-repository.git": error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
Falling back to the default image...
Solution:
ok - someone on Stackoverflow faced the same problem. I was trying to authenticate on the host with host_name:7080 but once I replaced host_name with localhost it just works. I don't know what is happening anymore
Jump to solution
23 Replies
Codercord
Codercordโ€ข2mo ago
<#1320899955531059220>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
I also ran $GIT_SSH_COMMAND from the container terminal, and it tells me:
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]
[-c cipher_spec] [-D [bind_address:]port] [-E log_file]
[-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]
[-J destination] [-L address] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-P tag] [-p port] [-R address]
[-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
destination [command [argument ...]]
ssh [-Q query_option]

Coder authenticates with git using the public
key below. All clones with SSH are authenticated automatically ๐Ÿช„.

ssh-ed25519 AAAAC3NzaC1lZXXXXXXXXXHIDINGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Add to GitHub and GitLab:
https://github.com/settings/ssh/new

https://gitlab.com/-/profile/keys

Encountered an error running "coder gitssh", see "coder gitssh --help" for more information
error: exit status 255
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]
[-c cipher_spec] [-D [bind_address:]port] [-E log_file]
[-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]
[-J destination] [-L address] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-P tag] [-p port] [-R address]
[-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
destination [command [argument ...]]
ssh [-Q query_option]

Coder authenticates with git using the public
key below. All clones with SSH are authenticated automatically ๐Ÿช„.

ssh-ed25519 AAAAC3NzaC1lZXXXXXXXXXHIDINGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Add to GitHub and GitLab:
https://github.com/settings/ssh/new

https://gitlab.com/-/profile/keys

Encountered an error running "coder gitssh", see "coder gitssh --help" for more information
error: exit status 255
running clone from the terminal also fails even though GIT_SSH_COMMAND is set - I think I'm missing something basic here:
/$ sudo git clone [email protected]:MyUsername/my-repository.git
Cloning into 'my-repository'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
/$ sudo git clone [email protected]:MyUsername/my-repository.git
Cloning into 'my-repository'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Phorcys
Phorcysโ€ข2mo ago
whoops sorry, I didn't see you're using envbuilder
Phorcys
Phorcysโ€ข2mo ago
I am away right now but see https://github.com/coder/envbuilder/issues/333 for more info
GitHub
Allow passing Git SSH key as an environment variable ยท Issue #333 ยท...
Following up to a discord conversation where an user tries to clone a Git repository via SSH and is met with the following error: envbuilder v1.0.0-rc.6+23d086e - Build development environments fro...
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
If I do that can I still use the template through?
Phorcys
Phorcysโ€ข2mo ago
yes
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
I should mention I'm not very smart. But from my perspective I put in a name, github URL (ssh), my github account has Coder SSH set. I click green button and it starts working. So my decision points are literally - SSH key and URL. Next part where I can change anything is .devcontainer folder with Dockerfile and everything else - but I can't get this far :c since I cannot clone the repository. I see the workaround description to just download the key to the environment - I just have no idea where in this user-scenario I can achieve it.
Luna Lovegood
Luna Lovegoodโ€ข2mo ago
use external Auth
data "coder_external_auth" "github" {
id = "primary-auth"
}
data "coder_external_auth" "github" {
id = "primary-auth"
}
And set token for envbuilder
"ENVBUILDER_GIT_USERNAME" : data.coder_external_auth.github.access_token,
"ENVBUILDER_GIT_USERNAME" : data.coder_external_auth.github.access_token,
you should setup external Auth for Coder agent first
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
you mean in the .tf file of my template? I can't change anything there. Publish is grayed out and nothing I do here's saved
Luna Lovegood
Luna Lovegoodโ€ข2mo ago
build it before publish
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
ok so I guess i'd do this here - but how?
No description
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
This Build works like every 10th time I click it, and keeps spitting 500 error to my browser console without any other feedback on what's wrong
Luna Lovegood
Luna Lovegoodโ€ข2mo ago
there is a link to document on that page what is message of 500 error?
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
It stopped with 500 - now it just keeps saying it cannot connect for logs and the thing keeps spinning and build never stops Running
No description
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
I've set the external Auth, I added the thing to .tf file, both environment variable "ENVBUILDER_GIT_USERNAME" : data.coder_external_auth.github.access_token, and the external auth. And I still get the same exact error:
#1: ๐Ÿ”‘ Using SSH authentication!
#1: ๐Ÿ”‘ No SSH key found, falling back to agent!
#1: โŒ Failed to connect to SSH agent: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
#1: ๐Ÿ”‘ Using SSH authentication!
#1: ๐Ÿ”‘ No SSH key found, falling back to agent!
#1: โŒ Failed to connect to SSH agent: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
this says we're good, I click the test, it says we're good. So what's wrong now?
No description
No description
Some Dinosaur
Some DinosaurOPโ€ข2mo ago
Ok so OAuth will never work with pulling repo through ssh - but with HTTPS it works. But I still want to know how to set up the alternative - pushing the SSH in a file.
Luna Lovegood
Luna Lovegoodโ€ข2mo ago
yeb, envbuilder doesn't use ssh setup by coder agent. If you want to use ssh to clone repo for envbuilder, pass ssh private key through
ENVBUILDER_SSH_PRIVATE_KEY_BASE64
ENVBUILDER_SSH_PRIVATE_KEY_BASE64
(or similar, check on their docs)
Phorcys
Phorcysโ€ข4w ago
hey @Some Dinosaur, did you figure it out?
Some Dinosaur
Some DinosaurOPโ€ข4w ago
I haven't got a chance to try passing the raw key yet. Ok, I tried to set up the same thing that worked with OAuth on a different machine. Now every time I click Click to Login I get:
{"message":"Cookie \"oauth_state\" must be provided."}
{"message":"Cookie \"oauth_state\" must be provided."}
Solution
Some Dinosaur
Some Dinosaurโ€ข4w ago
ok - someone on Stackoverflow faced the same problem. I was trying to authenticate on the host with host_name:7080 but once I replaced host_name with localhost it just works. I don't know what is happening anymore
Phorcys
Phorcysโ€ข3w ago
nice, this is still pretty weird though
Codercord
Codercordโ€ข3w ago
@Phorcys closed the thread.

Did you find this page helpful?