Provide git repo as parameter

Hey! First of all, amazing product. I love it so much already and I’ve barely scratched the surface. Right now I’m trying to create a baseline template for most of my projects, so naturally I want to be able to provide a repo as parameter to template and have it cloned on start. I copied what’s in https://coder.com/docs/templates/open-in-coder but I thought it would work as it does when I connect to a workspace and can immediately clone my repositories, since I’ve already added the Coder key. But instead the startup script fails when using ssh url, with something in the lines of “can’t connect to remote” etc etc. Why? 😄
Open in Coder - Coder Docs
Add an "Open in Coder" button to your repos
From An unknown user
From An unknown user
From An unknown user
20 Replies
Codercord
Codercord5mo ago
<#1264503474188713985>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Atif
Atif5mo ago
Git Clone - Coder Registry
Clone a Git repository by URL and skip if it exists.
GitHub
coder/dogfood/main.tf at 88d2dbd994cbb9eabbd3cd7d6a3e51fcb29d9fea ·...
Provision remote development environments via Terraform - coder/coder
Atif
Atif5mo ago
Glad that you are enjoying the product so far...
Phorcys
Phorcys5mo ago
glad that you're enjoing the product, could you send a screenshot of the error if what Atif sent doesn't work ?
joenas
joenasOP5mo ago
No description
No description
joenas
joenasOP5mo ago
Key cropped but that’s the log 🪵 Oh missed the previous reply, will test that first @Phorcys getting the same error with git_clone module
reating directory /home/jon/node-top-reddit...
Cloning [email protected]:joenas/node-top-reddit.git to /home/jon/node-top-reddit...
Cloning into '/home/jon/node-top-reddit'...
Host key verification failed.
reating directory /home/jon/node-top-reddit...
Cloning [email protected]:joenas/node-top-reddit.git to /home/jon/node-top-reddit...
Cloning into '/home/jon/node-top-reddit'...
Host key verification failed.
oh it's the known_hosts possibly?
Atif
Atif5mo ago
try using the https git url
joenas
joenasOP5mo ago
I think I’ve misunderstood how it works. To use git-clone I have to have git as a id provider? I figured since I can immediately clone etc when using the workspace in VScode that my credentials where already there
Phorcys
Phorcys4mo ago
not necessarily if the repo is private then you have to set up external auth for github yes (or allow your personal SSH key on your GitHub account)
joenas
joenasOP4mo ago
Yeah no it doesn’t work with public repositories either
Phorcys
Phorcys4mo ago
hey @joenas, any luck?
joenas
joenasOP4mo ago
Nah not really. Need to try again but in the meantime I found a work around with providing a github access token to the workspace via parameters and adding that to the git URL
Atif
Atif4mo ago
You could also use the resource coder_env.
joenas
joenasOP4mo ago
What’s that @Atif ?
joenas
joenasOP4mo ago
Ah yes I use that for other ENVs but unsure of which variable it would be in this case?
joenas
joenasOP4mo ago
Git Config - Coder Registry
Stores Git configuration from Coder credentials
joenas
joenasOP4mo ago
It's the known_hosts that's missing, if I never cloned anything in that workspace then I manually have to accept github.com on first clone. https works with public repo but not ssh I added this to my startup script
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -F github.com || ssh-keyscan github.com >> ~/.ssh/known_hosts
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -F github.com || ssh-keyscan github.com >> ~/.ssh/known_hosts
Phorcys
Phorcys3mo ago
hey @joenas, sorry for the lack of answer, thanks for sharing your results though!
Codercord
Codercord3mo ago
@Phorcys closed the thread.
Want results from more Discord servers?
Add your server