Skip to content

Conversation

Copy link

Copilot AI commented Dec 6, 2025

Description

When Coder is installed as a snap, config-ssh writes to ~/snap/coder/x3/.ssh/config instead of ~/.ssh/config because os.UserHomeDir() returns the snap's isolated home directory. This breaks standard SSH commands.

Changes

  • Added realHomeDir() helper that checks SNAP_REAL_HOME (set by snap to the actual user home) before falling back to os.UserHomeDir()
  • Updated path expansion in configSSH handler to use realHomeDir()
  • Added TestConfigSSH_SnapEnvironment to verify correct behavior in snap environments
func realHomeDir() (string, error) {
	// In snap environments, SNAP_REAL_HOME contains the actual user home.
	if snapHome := os.Getenv("SNAP_REAL_HOME"); snapHome != "" {
		return snapHome, nil
	}
	// Fall back to the standard method for non-snap environments.
	return os.UserHomeDir()
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 10.1.0.1
    • Triggering command: REDACTED, pid is -1 (packet block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>coder config-ssh when coder is installed sandboxed via snap is writing to wrong location</issue_title>
<issue_description>## Context
When Coder is installed as a snap package, coder config-ssh does not respect the default value of
--ssh-config-file which is ~/.ssh/config and instead writes config to ~/snap/coder/xX/.ssh/config.

See the console output.

coder config-ssh
WARN: The current executable path does not match the executable path found in $PATH.
  | This may cause issues connecting to your workspace via SSH.
  |     Current executable path: "/snap/coder/x3/coder"
  |     Executable path in $PATH: ""

> The following changes will be made to your SSH configuration:

    * Update the coder section in /home/atif/snap/coder/x3/.ssh/config

  Continue? (yes/no) yes

Updated "/home/atif/snap/coder/x3/.ssh/config"
You should now be able to ssh into your workspace.
For example, try running:

        $ ssh coder.coder

Problem

This causes ssh coder.coder to not work as there are no entries in ~/.ssh/config. coder ssh coder works fine.

Workaround

A workaround is to run coder config-ssh --ssh-config-file ~/.ssh/config which allows both coder ssh coder and ssh coder.coder to work.

Suggestion

coder config-ssh should use the correct default for --ssh-config-file argument.
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@cdr-bot cdr-bot bot added the community Pull Requests and issues created by the community. label Dec 6, 2025
@github-actions
Copy link

github-actions bot commented Dec 6, 2025


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copilot AI and others added 2 commits December 6, 2025 10:06
Added realHomeDir() function that respects SNAP_REAL_HOME environment variable to ensure config-ssh writes to the correct location in snap environments. Added test to verify the behavior.

Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ssh config location for snap installed coder fix: respect SNAP_REAL_HOME in config-ssh for snap installations Dec 6, 2025
Copilot AI requested a review from matifali December 6, 2025 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coder config-ssh when coder is installed sandboxed via snap is writing to wrong location

2 participants