Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Template] SSH Linux - Add support for deploying Coder on existing Linux systems (bare-metal installation)#605

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
IamTaoChen wants to merge12 commits intocoder:main
base:main
Choose a base branch
Loading
fromIamTaoChen:ssh-linux

Conversation

@IamTaoChen
Copy link

@IamTaoChenIamTaoChen commentedDec 15, 2025
edited
Loading

Description

A draft that allow user connect existing linux system though coder by ssh

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Template Information

Path:registry/IamTaoChen/templates/ssh-linux

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally

Related Issues

@IamTaoChenIamTaoChen changed the titletry to deploy coder on existed linux system[Template] SSH Linux - Add support for deploying Coder on existing Linux systems (bare-metal installation)Dec 15, 2025
@IamTaoChen
Copy link
Author

I'm not sure if this is needed by others and suitable, so it's just a draft

@matifali
Copy link
Member

Thanks for the contribution@IamTaoChen. Please move this to your own namespace. Follow the instructions here:https://coder.com/docs/about/contributing/templates

@IamTaoChenIamTaoChen marked this pull request as ready for reviewDecember 17, 2025 11:53
Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull request overview

This PR introduces a new Coder template that enables provisioning of existing Linux systems as Coder workspaces via SSH. The template supports both password and SSH key authentication methods, allowing users to deploy the Coder agent on bare-metal or pre-existing Linux installations without creating new infrastructure.

Key Changes

  • SSH-based deployment template with configurable authentication (password or SSH key)
  • Dynamic application selection (VS Code Desktop, VS Code Web, Cursor)
  • Automated agent lifecycle management with startup/stop provisioners

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
registry/IamTaoChen/templates/ssh-linux/main.tfTerraform configuration defining SSH connection, agent deployment, and application modules
registry/IamTaoChen/templates/ssh-linux/README.mdTemplate documentation covering prerequisites, architecture, parameters, and usage
registry/IamTaoChen/README.mdAuthor profile and template registry metadata
registry/IamTaoChen/.images/avatar.pngAuthor avatar image (binary)
.icons/linux.svgLinux/Tux icon for template display

@@ -0,0 +1,66 @@
---
display_name: Deploy Coder on existing Linux System
description: Provision an existing Linux system as a by deploying the Coder agent via SSH with this example template.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Grammatical error: "as a by deploying" should be "as a workspace by deploying" or simply "by deploying".

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fix


1. Create a new workspace in Coder using this template.
2. Fill in the parameters with your Linux system's details.
3. Start the workspace—Coden will connect via SSH and deploy the agent.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Typo: "Coden" should be "Coder".

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fix


###ssh-linux

Provision an existing Linux system as a by deploying the Coder agent via SSH with this example template.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Grammatical error: "as a by deploying" should be "as a workspace by deploying" or simply "by deploying".

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fix

Comment on lines +135 to +138
resource "random_integer" "vs_code_port" {
min = 54000
max = 55999
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Therandom_integer resource forvs_code_port is defined but only conditionally used when "VS Code Web" is selected. Consider moving this resource inside a conditional count or using a dynamic approach to avoid creating unnecessary resources when VS Code Web is not selected.

Copilot uses AI. Check for mistakes.
Comment on lines +195 to +202
connection {
type = "ssh"
host = data.coder_parameter.host.value
user = data.coder_parameter.username.value
port = data.coder_parameter.port.value
password = local.ssh_password
private_key = local.ssh_private_key
timeout = "5m"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Security concern: SSH credentials (password or private key) are stored in Terraform state and passed as environment variables. Consider adding documentation warning users about this security implication, especially for production use. Users should be aware that these credentials will be stored in the Terraform state file.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I want to use the ssh-key pair which generate by coder but I don't know how to read theprivate_key

" sleep 5",
" kill -KILL \"$PID\" || true",
" fi",
" rm -r ${local.coder_cache_dir}",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Potential bug: The agent cleanup on stop removes the entire cache directory withrm -r ${local.coder_cache_dir}. This will delete debug logs and potentially other workspace-specific data. Consider only removing the PID file or being more selective about what gets cleaned up, especially if users want to preserve logs for troubleshooting.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I want to rm all. thisdebug.log is valid while deploying failed

@IamTaoChen
Copy link
Author

After#606 merge, can add KasmVNC into apps

imageimage

Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull request overview

Copilot reviewed 3 out of 5 changed files in this pull request and generated 4 comments.

order = 1
validation {
regex = "^[a-zA-Z0-9:.%\\-]+$"
error = "Please enter a valid hostname, IPv4, or IPv6 address."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The validation error message could be more helpful by providing examples of valid formats. Consider updating to: "Please enter a valid hostname, IPv4, or IPv6 address. Examples: example.com, 192.168.1.1, or fe80::1"

Suggested change
error="Please enter a valid hostname, IPv4, or IPv6 address."
error="Please enter a valid hostname, IPv4, or IPv6 address. Examples: example.com, 192.168.1.1, or fe80::1"

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

update

Comment on lines +241 to +243
" kill -TERM \"$PID\" || true",
" sleep 5",
" kill -KILL \"$PID\" || true",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The kill command sequence may fail silently if the process doesn't exist or has already exited. Thekill -0 check is good, but between the check and the actual kill, the process could exit. Additionally,kill -KILL after a 5-second sleep may be too aggressive. Consider adding error handling and potentially increasing the grace period, or checking if the process is still running before sending SIGKILL.

Suggested change
" kill -TERM\"$PID\" || true",
" sleep 5",
" kill -KILL\"$PID\" || true",
" kill -TERM\"$PID\" 2>/dev/null || echo\"Warning: failed to send SIGTERM to process $PID\" >&2",
" for i in $(seq 1 10); do",
" if ! kill -0\"$PID\" 2>/dev/null; then",
" break",
" fi",
" sleep 1",
" done",
" if kill -0\"$PID\" 2>/dev/null; then",
" kill -KILL\"$PID\" 2>/dev/null || echo\"Warning: failed to send SIGKILL to process $PID\" >&2",
" fi",

Copilot uses AI. Check for mistakes.

1. Create a new workspace in Coder using this template.
2. Fill in the parameters with your Linux system's details.
3. Start the workspace—Codenr will connect via SSH and deploy the agent.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Typographical error: "Codenr" should be "Coder".

Suggested change
3. Start the workspace—Codenr will connect via SSH and deploy the agent.
3. Start the workspace—Coder will connect via SSH and deploy the agent.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fix

Comment on lines +210 to +215
"cat > $coder_sh << 'EOF'",
"${coder_agent.main.init_script}",
"EOF",
"chmod +x $coder_sh",
"echo \"$(date) : create $coder_sh\" >> ${local.coder_cache_dir}/debug.log",
"nohup env CODER_AGENT_TOKEN='${coder_agent.main.token}' $coder_sh > $log_file 2>&1 &",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Security concern: The CODER_AGENT_TOKEN is being passed as a plain environment variable in the remote-exec command. This exposes the token in process listings and logs on the remote system. Consider using a more secure method to pass the token, such as writing it to a file with restricted permissions first, or using Coder's built-in secure token handling mechanisms.

Suggested change
"cat > $coder_sh << 'EOF'",
"${coder_agent.main.init_script}",
"EOF",
"chmod +x $coder_sh",
"echo\"$(date) : create $coder_sh\" >>${local.coder_cache_dir}/debug.log",
"nohup env CODER_AGENT_TOKEN='${coder_agent.main.token}' $coder_sh > $log_file 2>&1 &",
"token_file=${local.coder_cache_dir}/coder_token",
"cat > $coder_sh << 'EOF'",
"${coder_agent.main.init_script}",
"EOF",
"chmod +x $coder_sh",
"umask 177 && printf '%s' '${coder_agent.main.token}' >\"$token_file\"",
"chmod 600\"$token_file\"",
"echo\"$(date) : create $coder_sh and token file $token_file\" >>${local.coder_cache_dir}/debug.log",
"nohup sh -c 'export CODER_AGENT_TOKEN=$(cat\"$1\"); exec\"$2\"' sh\"$token_file\"\"$coder_sh\" > $log_file 2>&1 &",

Copilot uses AI. Check for mistakes.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@DevelopmentCatsDevelopmentCatsAwaiting requested review from DevelopmentCats

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@IamTaoChen@matifali

[8]ページ先頭

©2009-2025 Movatter.jp