@@ -10,6 +10,7 @@ import (
10
10
"net"
11
11
"os"
12
12
"os/signal"
13
+ "slices"
13
14
"strings"
14
15
"syscall"
15
16
"text/template"
@@ -41,14 +42,14 @@ func (c *Connect) VerifyAndAppendNew(hostname string, remote net.Addr, key ssh.P
41
42
if len (c .TextAskWriteKnownHosts ) == 0 {
42
43
c .TextAskWriteKnownHosts += "The authenticity of host '{{.Address}} ({{.RemoteAddr}})' can't be established.\n "
43
44
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) )? "
45
46
}
46
47
47
48
// set TextAskOverwriteKnownHosts default text
48
49
if len (c .TextAskOverwriteKnownHosts ) == 0 {
49
50
c .TextAskOverwriteKnownHosts += "The authenticity of host '{{.Address}} ({{.RemoteAddr}})' can't be established.\n "
50
51
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) )? "
52
53
}
53
54
54
55
// check count KnownHostsFiles
@@ -156,9 +157,9 @@ func askAddingUnknownHostKey(text string, address string, remote net.Addr, key s
156
157
return false , fmt .Errorf ("failed to read answer: %s" , err )
157
158
}
158
159
answer = string (strings .ToLower (strings .TrimSpace (answer )))
159
- if answer == "yes" {
160
+ if slices . Contains ([] string { "yes" , "y" }, answer ) {
160
161
return true , nil
161
- } else if answer == "no" {
162
+ } else if slices . Contains ([] string { "no" , "n" }, answer ) {
162
163
return false , nil
163
164
}
164
165
fmt .Print ("Please type 'yes' or 'no': " )
0 commit comments