summaryrefslogtreecommitdiff
path: root/pkg/terminal/util.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-12-09 16:31:47 -0700
committerJhon Honce <jhonce@redhat.com>2020-12-10 15:32:37 -0700
commit7dd1da3787165f24d847885c26833bdfc1cbfedb (patch)
tree62a5f67fbf0fd7096acfcf131c9711cc201a3466 /pkg/terminal/util.go
parent6823a5d6cc771ed3c031518a759670dff7ee81b5 (diff)
downloadpodman-7dd1da3787165f24d847885c26833bdfc1cbfedb.tar.gz
podman-7dd1da3787165f24d847885c26833bdfc1cbfedb.tar.bz2
podman-7dd1da3787165f24d847885c26833bdfc1cbfedb.zip
Refine public key usage when remote
* Move all public key handling into one AuthMethod. Prioritize ssh-agent keys over identity files. * Cache server connection when tunneling, saves one RoundTrip on ssh handshake Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/terminal/util.go')
-rw-r--r--pkg/terminal/util.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/pkg/terminal/util.go b/pkg/terminal/util.go
index 169bec2af..231b47974 100644
--- a/pkg/terminal/util.go
+++ b/pkg/terminal/util.go
@@ -61,7 +61,7 @@ func ReadPassword(prompt string) (pw []byte, err error) {
}
}
-func PublicKey(path string, passphrase []byte) (ssh.AuthMethod, error) {
+func PublicKey(path string, passphrase []byte) (ssh.Signer, error) {
key, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
@@ -75,12 +75,9 @@ func PublicKey(path string, passphrase []byte) (ssh.AuthMethod, error) {
if len(passphrase) == 0 {
passphrase = ReadPassphrase()
}
- signer, err = ssh.ParsePrivateKeyWithPassphrase(key, passphrase)
- if err != nil {
- return nil, err
- }
+ return ssh.ParsePrivateKeyWithPassphrase(key, passphrase)
}
- return ssh.PublicKeys(signer), nil
+ return signer, nil
}
func ReadPassphrase() []byte {