mirror of https://github.com/containers/podman.git
Use current user if no user specified
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
This commit is contained in:
parent
e523734ab6
commit
48a8a9c22c
|
@ -9,6 +9,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -151,6 +152,13 @@ func sshClient(_url *url.URL, uri string, identity string, machine bool) (Connec
|
||||||
URI: _url,
|
URI: _url,
|
||||||
}
|
}
|
||||||
userinfo := _url.User
|
userinfo := _url.User
|
||||||
|
if _url.User == nil {
|
||||||
|
u, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
return connection, fmt.Errorf("current user could not be determined: %w", err)
|
||||||
|
}
|
||||||
|
userinfo = url.User(u.Username)
|
||||||
|
}
|
||||||
port := 22
|
port := 22
|
||||||
if _url.Port() != "" {
|
if _url.Port() != "" {
|
||||||
port, err = strconv.Atoi(_url.Port())
|
port, err = strconv.Atoi(_url.Port())
|
||||||
|
|
Loading…
Reference in New Issue