summaryrefslogtreecommitdiff
path: root/internal/ssh/client/simplecallback.go
diff options
context:
space:
mode:
authorPaul Bütow <pbuetow@mimecast.com>2020-02-11 13:10:26 +0000
committerPaul Bütow <pbuetow@mimecast.com>2020-02-11 13:10:26 +0000
commitecf7c86bc2f64068e6256ac1b9738c712a9858e9 (patch)
tree1ed536ad81a3c87c21eebd1438792ee91ce969e0 /internal/ssh/client/simplecallback.go
parent410ca88465f065f244f88c1d4089cb0fa4a45799 (diff)
more on scheduled jobs and ssh callbacks
Diffstat (limited to 'internal/ssh/client/simplecallback.go')
-rw-r--r--internal/ssh/client/simplecallback.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/ssh/client/simplecallback.go b/internal/ssh/client/simplecallback.go
new file mode 100644
index 0000000..580fa36
--- /dev/null
+++ b/internal/ssh/client/simplecallback.go
@@ -0,0 +1,36 @@
+package client
+
+import (
+ "context"
+ "net"
+
+ "golang.org/x/crypto/ssh"
+)
+
+// SimpleCallback is a wrapper around ssh.KnownHosts so that we can add all
+// unknown hosts in a single batch to the known_hosts file.
+type SimpleCallback struct {
+}
+
+// NewSimpleCallback returns a new wrapper.
+func NewSimpleCallback() (SimpleCallback, error) {
+ return SimpleCallback{}, nil
+}
+
+// Wrap the host key callback.
+func (SimpleCallback) Wrap() ssh.HostKeyCallback {
+ return func(server string, remote net.Addr, key ssh.PublicKey) error {
+ return nil
+ }
+}
+
+// Untrusted returns whether host is not trusted or not.
+func (SimpleCallback) Untrusted(server string) bool {
+ return false
+}
+
+// PromptAddHosts prompts a question to the user whether unknown hosts should
+// be added to the known hosts or not.
+func (SimpleCallback) PromptAddHosts(ctx context.Context) {
+ // Not used here.
+}