Merge pull request #6739 from jwhonce/wip/connection

Fix ssh-agent support
This commit is contained in:
OpenShift Merge Robot
2020-06-24 09:24:24 -04:00
committed by GitHub
2 changed files with 10 additions and 7 deletions

View File

@ -42,7 +42,7 @@ var (
RunE: connection, RunE: connection,
Example: `podman system connection server.fubar.com Example: `podman system connection server.fubar.com
podman system connection --identity ~/.ssh/dev_rsa ssh://root@server.fubar.com:2222 podman system connection --identity ~/.ssh/dev_rsa ssh://root@server.fubar.com:2222
podman system connection --identity ~/.ssh/dev_rsa -port 22 root@server.fubar.com`, podman system connection --identity ~/.ssh/dev_rsa --port 22 root@server.fubar.com`,
} }
cOpts = struct { cOpts = struct {
@ -202,7 +202,7 @@ func getUDS(cmd *cobra.Command, uri *url.URL) (string, error) {
return "", errors.Wrapf(err, "failed to parse 'podman info' results") return "", errors.Wrapf(err, "failed to parse 'podman info' results")
} }
if info.Host.RemoteSocket == nil || !info.Host.RemoteSocket.Exists { if info.Host.RemoteSocket == nil || len(info.Host.RemoteSocket.Path) == 0 {
return "", fmt.Errorf("remote podman %q failed to report its UDS socket", uri.Host) return "", fmt.Errorf("remote podman %q failed to report its UDS socket", uri.Host)
} }
return info.Host.RemoteSocket.Path, nil return info.Host.RemoteSocket.Path, nil

View File

@ -181,12 +181,15 @@ func pingNewConnection(ctx context.Context) error {
func sshClient(_url *url.URL, secure bool, passPhrase string, identity string) (Connection, error) { func sshClient(_url *url.URL, secure bool, passPhrase string, identity string) (Connection, error) {
authMethods := []ssh.AuthMethod{} authMethods := []ssh.AuthMethod{}
if len(identity) > 0 {
auth, err := terminal.PublicKey(identity, []byte(passPhrase)) auth, err := terminal.PublicKey(identity, []byte(passPhrase))
if err != nil { if err != nil {
return Connection{}, errors.Wrapf(err, "failed to parse identity %q", identity) return Connection{}, errors.Wrapf(err, "failed to parse identity %q", identity)
} }
logrus.Debugf("public key signer enabled for identity %q", identity) logrus.Debugf("public key signer enabled for identity %q", identity)
authMethods = append(authMethods, auth) authMethods = append(authMethods, auth)
}
if sock, found := os.LookupEnv("SSH_AUTH_SOCK"); found { if sock, found := os.LookupEnv("SSH_AUTH_SOCK"); found {
logrus.Debugf("Found SSH_AUTH_SOCK %q, ssh-agent signer enabled", sock) logrus.Debugf("Found SSH_AUTH_SOCK %q, ssh-agent signer enabled", sock)