Skip to content

Commit

Permalink
unkown host
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Aug 2, 2024
1 parent e2db963 commit d933b9d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion spaceship/pkg/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import (
"context"
"fmt"
"net/url"
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/ignite/cli/v28/ignite/pkg/errors"
"github.com/ignite/cli/v28/ignite/pkg/gocmd"
"github.com/ignite/cli/v28/ignite/pkg/randstr"
"github.com/manifoldco/promptui"
"github.com/melbahja/goph"
"github.com/pkg/sftp"
"golang.org/x/crypto/ssh/knownhosts"
)

const (
Expand Down Expand Up @@ -177,7 +180,19 @@ func (s *SSH) Connect() error {
return err
}

s.client, err = goph.NewUnknown(s.username, s.host, auth)
s.client, err = goph.New(s.username, s.host, auth)
if errors.Is(err, &knownhosts.KeyError{}) {
prompt := promptui.Prompt{
Label: fmt.Sprintf("Unknown host: %s. Do you want to proceed with the connection anyway", s.host),
IsConfirm: true,
Stdout: os.Stdout,
Stdin: os.Stdin,
}
if _, err := prompt.Run(); err != nil {
return err
}
s.client, err = goph.NewUnknown(s.username, s.host, auth)
}
if err != nil {
return errors.Wrapf(err, "Failed to connect to %v", s)
}
Expand Down

0 comments on commit d933b9d

Please sign in to comment.