From 444efe3d31384722d239113e533b3acfa834ed56 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 2 Jul 2017 13:45:34 +0200 Subject: [PATCH] Added showHostKey function --- Main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Main.go b/Main.go index 4f68bd6..cde47b7 100644 --- a/Main.go +++ b/Main.go @@ -3,8 +3,10 @@ package main import ( "fmt" "log" + "net" "os" "runtime" + "time" "github.com/SommerEngineering/Sync/Sync" "github.com/howeyc/gopass" @@ -14,7 +16,7 @@ import ( func main() { // Show the current version: - log.Println(`Sync v1.3.0`) + log.Println(`Sync v1.3.1`) // Allow Go to use all CPUs: runtime.GOMAXPROCS(runtime.NumCPU()) @@ -97,6 +99,7 @@ func main() { ssh.PasswordCallback(Sync.PasswordCallback), ssh.KeyboardInteractive(Sync.KeyboardInteractiveChallenge), }, + HostKeyCallback: showHostKey(), } // Connect to the SSH server: @@ -111,3 +114,11 @@ func main() { Sync.Synchronise(ssh, supervised, pushOnly, localDir, remoteDir) log.Println("Synchronising done.") } + +func showHostKey() ssh.HostKeyCallback { + return func(hostname string, remote net.Addr, key ssh.PublicKey) error { + log.Printf("Your server's hostname is %s (%s) and its public key is %s. If this is wrong, please abort the program now! Wait 16 seconds for your check.", hostname, remote.String(), ssh.FingerprintSHA256(key)) + time.Sleep(16 * time.Second) + return nil + } +}