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 (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -99,7 +100,7 @@ func NewHostKeyCbk() HostKeyCallback {
|
||||||
msg := `The authenticity of host %s cannot be established.
|
msg := `The authenticity of host %s cannot be established.
|
||||||
%s key fingerprint is %s
|
%s key fingerprint is %s
|
||||||
Are you sure you want to continue connecting (yes/no)? `
|
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)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
answer, err := reader.ReadString('\n')
|
answer, err := reader.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -110,6 +111,8 @@ Are you sure you want to continue connecting (yes/no)? `
|
||||||
|
|
||||||
if answer == "yes" || answer == "y" {
|
if answer == "yes" || answer == "y" {
|
||||||
trust = pubKey.Marshal()
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue