File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package sshutil
33import (
44 "errors"
55 "fmt"
6+ "io/fs"
67 "os"
78 "os/exec"
89 "os/user"
@@ -110,7 +111,7 @@ func CommonArgs(useDotSSH bool) ([]string, error) {
110111 }
111112 args := []string {"-i" , privateKeyPath }
112113
113- // Append all private keys corresponding to ~/.ssh/*.pub to keep old instances workin
114+ // Append all private keys corresponding to ~/.ssh/*.pub to keep old instances working
114115 // that had been created before lima started using an internal identity.
115116 if useDotSSH {
116117 homeDir , err := os .UserHomeDir ()
@@ -127,7 +128,16 @@ func CommonArgs(useDotSSH bool) ([]string, error) {
127128 }
128129 privateKeyPath := strings .TrimSuffix (f , ".pub" )
129130 _ , err = os .Stat (privateKeyPath )
131+ if errors .Is (err , fs .ErrNotExist ) {
132+ // Skip .pub files without a matching private key. This is reasonably common,
133+ // due to major projects like Vault recommending the ${name}-cert.pub format
134+ // for SSH certificate files.
135+ //
136+ // e.g. https://www.vaultproject.io/docs/secrets/ssh/signed-ssh-certificates
137+ continue
138+ }
130139 if err != nil {
140+ // Fail on permission-related and other path errors
131141 return nil , err
132142 }
133143 args = append (args , "-i" , privateKeyPath )
You can’t perform that action at this time.
0 commit comments