@@ -29,7 +29,8 @@ import (
29
29
const (
30
30
sshDefaultConfigFileName = "~/.ssh/config"
31
31
sshDefaultCoderConfigFileName = "~/.ssh/coder"
32
- sshCoderConfigHeader = `# This file is managed by coder. DO NOT EDIT.
32
+ sshCoderConfigHeader = "# This file is managed by coder. DO NOT EDIT."
33
+ sshCoderConfigDocsHeader = `
33
34
#
34
35
# You should not hand-edit this file, all changes will be lost upon workspace
35
36
# creation, deletion or when running "coder config-ssh".
@@ -133,6 +134,11 @@ func configSSH() *cobra.Command {
133
134
if err != nil && ! errors .Is (err , fs .ErrNotExist ) {
134
135
return xerrors .Errorf ("read ssh config failed: %w" , err )
135
136
}
137
+ if len (coderConfigRaw ) > 0 {
138
+ if ! bytes .HasPrefix (coderConfigRaw , []byte (sshCoderConfigHeader )) {
139
+ return xerrors .Errorf ("unexpected content in %s: remove the file and rerun the command to continue" , coderConfigFile )
140
+ }
141
+ }
136
142
137
143
// Keep track of changes we are making.
138
144
var changes []string
@@ -192,6 +198,7 @@ func configSSH() *cobra.Command {
192
198
193
199
buf := & bytes.Buffer {}
194
200
_ , _ = buf .WriteString (sshCoderConfigHeader )
201
+ _ , _ = buf .WriteString (sshCoderConfigDocsHeader )
195
202
196
203
// Store the provided flags as part of the
197
204
// config for future (re)use.
0 commit comments