mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: create ssh directory if it doesn't already exist when running coder config-ssh (#17711)
Closes [coder/internal#623](https://github.com/coder/internal/issues/623) > [!WARNING] > PR co-authored by Claude Code
This commit is contained in:
@@ -440,6 +440,11 @@ func (r *RootCmd) configSSH() *serpent.Command {
|
||||
}
|
||||
|
||||
if !bytes.Equal(configRaw, configModified) {
|
||||
sshDir := filepath.Dir(sshConfigFile)
|
||||
if err := os.MkdirAll(sshDir, 0700); err != nil {
|
||||
return xerrors.Errorf("failed to create directory %q: %w", sshDir, err)
|
||||
}
|
||||
|
||||
err = atomic.WriteFile(sshConfigFile, bytes.NewReader(configModified))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("write ssh config failed: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user