@@ -176,10 +176,12 @@ func CreateLink(alias string, keyMap map[string]*SSHKey, env *Environment) {
176
176
if ! found {
177
177
return
178
178
}
179
+
179
180
relStorePath , err := filepath .Rel (env .SSHPath , env .StorePath )
180
181
if err != nil {
181
182
fmt .Println ("Failed to find rel store path" )
182
183
}
184
+
183
185
//Create symlink for private key
184
186
if err := os .Symlink (filepath .Join (relStorePath , alias , key .Type .PrivateKey ()), filepath .Join (env .SSHPath , key .Type .PrivateKey ())); err != nil {
185
187
fmt .Println ("Failed to create symble link for private key" )
@@ -196,7 +198,7 @@ func CreateLink(alias string, keyMap map[string]*SSHKey, env *Environment) {
196
198
func loadSingleKey (keyPath string , env * Environment ) * SSHKey {
197
199
key := & SSHKey {}
198
200
199
- //Walkthrough SSH key store and load all the keys
201
+ //Walk-through SSH key store and load all the keys
200
202
err := filepath .Walk (keyPath , func (path string , f os.FileInfo , err error ) error {
201
203
if f == nil {
202
204
return err
@@ -224,7 +226,13 @@ func loadSingleKey(keyPath string, env *Environment) *SSHKey {
224
226
//Check if key is in use
225
227
key .PrivateKey = path
226
228
227
- if path == ParsePath (filepath .Join (env .SSHPath , kt .KeyBaseName )) {
229
+ parsedPath := ParsePath (filepath .Join (env .SSHPath , kt .KeyBaseName ))
230
+ absPath , err := filepath .Abs (filepath .Join (env .SSHPath , parsedPath ))
231
+ if err != nil {
232
+ return nil
233
+ }
234
+
235
+ if path == absPath {
228
236
key .IsDefault = true
229
237
}
230
238
@@ -268,7 +276,7 @@ func ParsePath(path string) string {
268
276
func LoadSSHKeys (env * Environment ) map [string ]* SSHKey {
269
277
keys := map [string ]* SSHKey {}
270
278
271
- //Walkthrough SSH key store and load all the keys
279
+ //Walk-through SSH key store and load all the keys
272
280
err := filepath .Walk (env .StorePath , func (path string , f os.FileInfo , err error ) error {
273
281
if f == nil {
274
282
return err
0 commit comments