mirror of https://github.com/knative/func.git
Hint to user when ssh server key is not known (#885)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
parent
2d23c9cd1f
commit
917a8efdb2
|
@ -3,6 +3,7 @@ package ssh
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -99,7 +100,7 @@ func NewHostKeyCbk() HostKeyCallback {
|
|||
msg := `The authenticity of host %s cannot be established.
|
||||
%s key fingerprint is %s
|
||||
Are you sure you want to continue connecting (yes/no)? `
|
||||
fmt.Fprintf(os.Stdout, msg, hostPort, pubKey.Type(), ssh.FingerprintSHA256(pubKey))
|
||||
fmt.Fprintf(os.Stderr, msg, hostPort, pubKey.Type(), ssh.FingerprintSHA256(pubKey))
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
answer, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
|
@ -110,6 +111,8 @@ Are you sure you want to continue connecting (yes/no)? `
|
|||
|
||||
if answer == "yes" || answer == "y" {
|
||||
trust = pubKey.Marshal()
|
||||
fmt.Fprintf(os.Stderr, "To avoid this in future add following line into your ~/.ssh/known_hosts:\n%s %s %s\n",
|
||||
hostPort, pubKey.Type(), base64.StdEncoding.EncodeToString(trust))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue