Skip to content

Commit

Permalink
podman-remote fixes for msi and client
Browse files Browse the repository at this point in the history
correct small typo that sets the path on windows via the msi xml.

in the remote client, prompt for SSH password when no identity or alternate means of authentication are provided.

Signed-off-by: Brent Baude <[email protected]>
  • Loading branch information
baude committed Aug 12, 2020
1 parent 8eaacec commit 6ff4239
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions cmd/podman/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ func resolveDestination() (string, string) {

cfg, err := config.ReadCustomConfig()
if err != nil {
logrus.Warning(errors.Wrap(err, "unable to read local containers.conf"))
return registry.DefaultAPIAddress(), ""
}

Expand Down
13 changes: 11 additions & 2 deletions cmd/podman/system/connection/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func add(cmd *cobra.Command, args []string) error {
cfg.Engine.ServiceDestinations = map[string]config.Destination{
args[0]: dst,
}
cfg.Engine.ActiveService = args[0]
} else {
cfg.Engine.ServiceDestinations[args[0]] = dst
}
Expand Down Expand Up @@ -181,12 +182,20 @@ func getUDS(cmd *cobra.Command, uri *url.URL) (string, error) {
authMethods = append(authMethods, ssh.PublicKeysCallback(a.Signers))
}

config := &ssh.ClientConfig{
if len(authMethods) == 0 {
pass, err := terminal.ReadPassword(fmt.Sprintf("%s's login password:", uri.User.Username()))
if err != nil {
return "", err
}
authMethods = append(authMethods, ssh.Password(string(pass)))
}

cfg := &ssh.ClientConfig{
User: uri.User.Username(),
Auth: authMethods,
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}
dial, err := ssh.Dial("tcp", uri.Host, config)
dial, err := ssh.Dial("tcp", uri.Host, cfg)
if err != nil {
return "", errors.Wrapf(err, "failed to connect to %q", uri.Host)
}
Expand Down
5 changes: 2 additions & 3 deletions contrib/msi/podman.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@
<CreateFolder/>
</Component>
<Component Id="MainExecutable" Guid="73752F94-6589-4C7B-ABED-39D655A19714">
<File Id="520C6E17-77A2-4F41-9611-30FA763A0702" Name="podman-remote-windows.exe" Source="bin/podman-remote-windows.exe"/>
<File Id="A14218A0-4180-44AC-B109-7C63B3099DCA" Name="podman.bat" Source="podman.bat" KeyPath="yes"/>
<File Id="520C6E17-77A2-4F41-9611-30FA763A0702" Name="podman.exe" Source="bin/podman-remote-windows.exe" KeyPath="yes"/>
</Component>
</Directory>
</Directory>
</Directory>
</Directory>

<Property Id="setx" Value="setx.exe"/>
<CustomAction Id="ChangePath" ExeCommand="PATH &quot;%PATH%;[INSTALLDIR] &quot;" Property="setx" Execute="deferred" Impersonate="yes" Return="check"/>
<CustomAction Id="ChangePath" ExeCommand="PATH &quot;%PATH%;[INSTALLDIR]&quot;" Property="setx" Execute="deferred" Impersonate="yes" Return="check"/>

<Feature Id="Complete" Level="1">
<ComponentRef Id="INSTALLDIR_Component"/>
Expand Down
10 changes: 9 additions & 1 deletion pkg/bindings/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ func pingNewConnection(ctx context.Context) error {
}

func sshClient(_url *url.URL, secure bool, passPhrase string, identity string) (Connection, error) {
// if you modify the authmethods or their conditionals, you will also need to make similar
// changes in the client (currently cmd/podman/system/connection/add getUDS).
authMethods := []ssh.AuthMethod{}

if len(identity) > 0 {
auth, err := terminal.PublicKey(identity, []byte(passPhrase))
if err != nil {
Expand All @@ -205,6 +206,13 @@ func sshClient(_url *url.URL, secure bool, passPhrase string, identity string) (
if pw, found := _url.User.Password(); found {
authMethods = append(authMethods, ssh.Password(pw))
}
if len(authMethods) == 0 {
pass, err := terminal.ReadPassword("Login password:")
if err != nil {
return Connection{}, err
}
authMethods = append(authMethods, ssh.Password(string(pass)))
}

callback := ssh.InsecureIgnoreHostKey()
if secure {
Expand Down

0 comments on commit 6ff4239

Please sign in to comment.