@@ -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".
@@ -131,6 +132,11 @@ func configSSH() *cobra.Command {
131
132
if err != nil && ! errors .Is (err , fs .ErrNotExist ) {
132
133
return xerrors .Errorf ("read ssh config failed: %w" , err )
133
134
}
135
+ if len (coderConfigRaw ) > 0 {
136
+ if ! bytes .HasPrefix (coderConfigRaw , []byte (sshCoderConfigHeader )) {
137
+ return xerrors .Errorf ("unexpected content in %s: remove the file and rerun the command to continue" , coderConfigFile )
138
+ }
139
+ }
134
140
135
141
// Keep track of changes we are making.
136
142
var changes []string
@@ -190,6 +196,7 @@ func configSSH() *cobra.Command {
190
196
191
197
buf := & bytes.Buffer {}
192
198
_ , _ = buf .WriteString (sshCoderConfigHeader )
199
+ _ , _ = buf .WriteString (sshCoderConfigDocsHeader )
193
200
194
201
// Store the provided flags as part of the
195
202
// config for future (re)use.
0 commit comments