|
1 | 1 | package sshutil
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "fmt" |
5 | 4 | "os"
|
6 | 5 | "os/exec"
|
7 | 6 | "os/user"
|
@@ -98,25 +97,6 @@ func DefaultPubKeys(loadDotSSH bool) ([]PubKey, error) {
|
98 | 97 | return res, nil
|
99 | 98 | }
|
100 | 99 |
|
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 |
| - |
120 | 100 | func CommonArgs(useDotSSH bool) ([]string, error) {
|
121 | 101 | configDir, err := store.LimaConfigDir()
|
122 | 102 | if err != nil {
|
@@ -155,6 +135,7 @@ func CommonArgs(useDotSSH bool) ([]string, error) {
|
155 | 135 |
|
156 | 136 | args = append(args,
|
157 | 137 | "-o", "StrictHostKeyChecking=no",
|
| 138 | + "-o", "UserKnownHostsFile=/dev/null", |
158 | 139 | "-o", "NoHostAuthenticationForLocalhost=yes",
|
159 | 140 | "-o", "GSSAPIAuthentication=no",
|
160 | 141 | "-o", "PreferredAuthentications=publickey",
|
|
0 commit comments