- Notifications
You must be signed in to change notification settings - Fork928
Description
Feature request
It would be nice if we could automatically update coder SSH config oncoder create
andcoder delete
.
With#1900 merged, the coder SSH config is now a separate file we can safely edit without causing trouble for the user (~/.ssh/coder
).
Why is this useful?
- It removes an extra step, the user only needs to run
coder config-ssh
once - After
coder create
the workspace automatically will show up in e.g. vscode remote explorer
Potential problems
- Simultaneous writes to
~/.ssh/coder
from multiple coder instances (rare edge case)
To work around the simultaneous write, we can grab a flock on the file, fetch the most recent workspaces, write, release flock. This will work as a kind of mutex ensuring each separate process only writes the latest workspaces to the file.
Can we do this byonly using glob-hosts in~/.ssh/coder
?
No.
Using a glob host in~/.ssh/coder
would allow forssh coder.workspace
to work without any additional updates to the config:
Host coder.*...
However, this does not allow tools like VSCode Remote Explorer to detect the hostnames/workspaces, nor does it work for shell autocomplete. So even if we use globs or not, we will want to write the actual workspaces to the config.
There's also a small risk of matching valid domain names, likessh coder.[TLD]
where TLD is a valid top-level domain like.work
,.edu
,.jobs
, etc.