File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -88,9 +88,16 @@ func appendKnownHelper(nodeName string, appendKnown bool) {
88
88
if port != 22 {
89
89
host = fmt .Sprintf ("[%s]:%d" , addr , port )
90
90
}
91
- knownHosts := filepath .Join (homedir .HomeDir (), ".ssh" , "known_hosts" )
92
91
93
- fmt .Fprintf (os .Stderr , "Host added: %s (%s)\n " , knownHosts , host )
92
+ sshDir := filepath .Join (homedir .HomeDir (), ".ssh" )
93
+ err = os .MkdirAll (sshDir , os .FileMode (0700 )) // drwx------, to match ssh-keygen behavior
94
+ if err != nil {
95
+ out .ErrLn ("MkdirAll: %v" , err )
96
+ os .Exit (1 )
97
+ }
98
+
99
+ knownHosts := filepath .Join (sshDir , "known_hosts" )
100
+
94
101
if sshutil .KnownHost (host , knownHosts ) {
95
102
return
96
103
}
@@ -113,6 +120,8 @@ func appendKnownHelper(nodeName string, appendKnown bool) {
113
120
os .Exit (1 )
114
121
}
115
122
123
+ fmt .Fprintf (os .Stderr , "Host added: %s (%s)\n " , knownHosts , host )
124
+
116
125
return
117
126
}
118
127
}
You can’t perform that action at this time.
0 commit comments