Skip to content

Commit 2dcc933

Browse files
committed
update. change knownhost ask
1 parent ac25048 commit 2dcc933

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

knownhosts.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"net"
1111
"os"
1212
"os/signal"
13+
"slices"
1314
"strings"
1415
"syscall"
1516
"text/template"
@@ -41,14 +42,14 @@ func (c *Connect) VerifyAndAppendNew(hostname string, remote net.Addr, key ssh.P
4142
if len(c.TextAskWriteKnownHosts) == 0 {
4243
c.TextAskWriteKnownHosts += "The authenticity of host '{{.Address}} ({{.RemoteAddr}})' can't be established.\n"
4344
c.TextAskWriteKnownHosts += "RSA key fingerprint is {{.Fingerprint}}\n"
44-
c.TextAskWriteKnownHosts += "Are you sure you want to continue connecting (yes/no)? "
45+
c.TextAskWriteKnownHosts += "Are you sure you want to continue connecting ((yes|y)/(no|n))? "
4546
}
4647

4748
// set TextAskOverwriteKnownHosts default text
4849
if len(c.TextAskOverwriteKnownHosts) == 0 {
4950
c.TextAskOverwriteKnownHosts += "The authenticity of host '{{.Address}} ({{.RemoteAddr}})' can't be established.\n"
5051
c.TextAskOverwriteKnownHosts += "Old key: {{.OldKeyText}}\n"
51-
c.TextAskOverwriteKnownHosts += "Are you sure you want to overwrite {{.Fingerprint}}, continue connecting (yes/no)? "
52+
c.TextAskOverwriteKnownHosts += "Are you sure you want to overwrite {{.Fingerprint}}, continue connecting ((yes|y)/(no|n))? "
5253
}
5354

5455
// check count KnownHostsFiles
@@ -156,9 +157,9 @@ func askAddingUnknownHostKey(text string, address string, remote net.Addr, key s
156157
return false, fmt.Errorf("failed to read answer: %s", err)
157158
}
158159
answer = string(strings.ToLower(strings.TrimSpace(answer)))
159-
if answer == "yes" {
160+
if slices.Contains([]string{"yes", "y"}, answer) {
160161
return true, nil
161-
} else if answer == "no" {
162+
} else if slices.Contains([]string{"no", "n"}, answer) {
162163
return false, nil
163164
}
164165
fmt.Print("Please type 'yes' or 'no': ")

0 commit comments

Comments
 (0)