From 4e59fd77a80a6295eb8dbf79991e1648bc739302 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Tue, 23 Jun 2020 18:50:09 -0700 Subject: Fix ssh-agent support * An identity of "" implies ssh-agent and user/password to be used * Fixed example Signed-off-by: Jhon Honce --- pkg/bindings/connection.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'pkg/bindings/connection.go') diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go index 584aa55c1..c02d55e31 100644 --- a/pkg/bindings/connection.go +++ b/pkg/bindings/connection.go @@ -181,12 +181,15 @@ func pingNewConnection(ctx context.Context) error { func sshClient(_url *url.URL, secure bool, passPhrase string, identity string) (Connection, error) { authMethods := []ssh.AuthMethod{} - auth, err := terminal.PublicKey(identity, []byte(passPhrase)) - if err != nil { - return Connection{}, errors.Wrapf(err, "failed to parse identity %q", identity) + + if len(identity) > 0 { + auth, err := terminal.PublicKey(identity, []byte(passPhrase)) + if err != nil { + return Connection{}, errors.Wrapf(err, "failed to parse identity %q", identity) + } + logrus.Debugf("public key signer enabled for identity %q", identity) + authMethods = append(authMethods, auth) } - logrus.Debugf("public key signer enabled for identity %q", identity) - authMethods = append(authMethods, auth) if sock, found := os.LookupEnv("SSH_AUTH_SOCK"); found { logrus.Debugf("Found SSH_AUTH_SOCK %q, ssh-agent signer enabled", sock) -- cgit v1.2.3-54-g00ecf