@@ -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