Skip to content

Commit 08d4bc3

Browse files
committed
SSH: Remove RemoveKnownHostEntries()
We no longer attempt to touch the known_hosts file. Signed-off-by: Mark Yen <[email protected]>
1 parent 4feb708 commit 08d4bc3

File tree

2 files changed

+0
-24
lines changed

2 files changed

+0
-24
lines changed

pkg/hostagent/hostagent.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ func (a *HostAgent) Run(ctx context.Context) error {
174174
}
175175
stBooting := stBase
176176
a.emitEvent(ctx, hostagentapi.Event{Status: stBooting})
177-
if err := sshutil.RemoveKnownHostEntries(sshLocalPort); err != nil {
178-
a.l.WithError(err).Error("couldn't remove existing localhost host keys")
179-
return err
180-
}
181177

182178
go func() {
183179
stRunning := stBase

pkg/sshutil/sshutil.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package sshutil
22

33
import (
4-
"fmt"
54
"os"
65
"os/exec"
76
"os/user"
@@ -98,25 +97,6 @@ func DefaultPubKeys(loadDotSSH bool) ([]PubKey, error) {
9897
return res, nil
9998
}
10099

101-
func RemoveKnownHostEntries(sshLocalPort int) error {
102-
homeDir, err := os.UserHomeDir()
103-
if err != nil {
104-
return err
105-
}
106-
// `ssh-keygen -R` will return a non-0 status when ~/.ssh/known_hosts doesn't exist
107-
if _, err := os.Stat(filepath.Join(homeDir, ".ssh/known_hosts")); errors.Is(err, os.ErrNotExist) {
108-
return nil
109-
}
110-
sshFixCmd := exec.Command("ssh-keygen",
111-
"-R", fmt.Sprintf("[127.0.0.1]:%d", sshLocalPort),
112-
"-R", fmt.Sprintf("[localhost]:%d", sshLocalPort),
113-
)
114-
if out, err := sshFixCmd.CombinedOutput(); err != nil {
115-
return errors.Wrapf(err, "failed to run %v: %q", sshFixCmd.Args, string(out))
116-
}
117-
return nil
118-
}
119-
120100
func CommonArgs(useDotSSH bool) ([]string, error) {
121101
configDir, err := store.LimaConfigDir()
122102
if err != nil {

0 commit comments

Comments
 (0)