Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ssh config handling #88

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions cmd/rigtest/rigtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/k0sproject/rig/os"
"github.com/k0sproject/rig/os/registry"
_ "github.com/k0sproject/rig/os/support"
"github.com/kevinburke/ssh_config"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -112,24 +111,6 @@ func main() {
goos.Exit(1)
}

if configPath := goos.Getenv("SSH_CONFIG"); configPath != "" {
f, err := goos.Open(configPath)
if err != nil {
panic(err)
}
cfg, err := ssh_config.Decode(f)
if err != nil {
panic(err)
}
rig.SSHConfigGetAll = func(dst, key string) []string {
res, err := cfg.GetAll(dst, key)
if err != nil {
return nil
}
return res
}
}

var passfunc func() (string, error)
if *pc {
passfunc = func() (string, error) {
Expand All @@ -141,16 +122,16 @@ func main() {
}

var hosts []*Host
var port *int

for _, address := range strings.Split(*dh, ",") {
port := 22
if addr, portstr, ok := strings.Cut(address, ":"); ok {
address = addr
p, err := strconv.Atoi(portstr)
if err != nil {
panic("invalid port " + portstr)
}
port = p
port = &p
}

var h *Host
Expand All @@ -172,7 +153,7 @@ func main() {
Connection: rig.Connection{
WinRM: &rig.WinRM{
Address: *dh,
Port: port,
Port: *port,
User: *usr,
UseHTTPS: *https,
Insecure: true,
Expand Down
Loading