Skip to content

Commit

Permalink
Merge pull request #10675 from rifelpet/dump-user
Browse files Browse the repository at this point in the history
Allow SSH user to be overridden for `toolbox dump`
  • Loading branch information
k8s-ci-robot authored Jan 29, 2021
2 parents 08128f6 + 2d8bfc0 commit 6afbfe1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/kops/toolbox_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ type ToolboxDumpOptions struct {

Dir string
PrivateKey string
SSHUser string
}

func (o *ToolboxDumpOptions) InitDefaults() {
o.Output = OutputYaml
o.PrivateKey = "~/.ssh/id_rsa"
o.SSHUser = "ubuntu"
}

func NewCmdToolboxDump(f *util.Factory, out io.Writer) *cobra.Command {
Expand Down Expand Up @@ -100,6 +102,7 @@ func NewCmdToolboxDump(f *util.Factory, out io.Writer) *cobra.Command {

cmd.Flags().StringVar(&options.Dir, "dir", options.Dir, "target directory; if specified will collect logs and other information.")
cmd.Flags().StringVar(&options.PrivateKey, "private-key", options.PrivateKey, "private key to use for SSH acccess to instances")
cmd.Flags().StringVar(&options.SSHUser, "ssh-user", options.SSHUser, "the remote user for SSH access to instances")

return cmd
}
Expand Down Expand Up @@ -183,10 +186,9 @@ func RunToolboxDump(ctx context.Context, f *util.Factory, out io.Writer, options
}
}

// TODO: We need to find the correct SSH user, ideally per IP
sshUser := "ubuntu"
sshConfig := &ssh.ClientConfig{
User: sshUser,
Config: ssh.Config{},
User: options.SSHUser,
Auth: []ssh.AuthMethod{
ssh.PublicKeys(signer),
},
Expand Down
1 change: 1 addition & 0 deletions docs/cli/kops_toolbox_dump.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ kops toolbox dump [flags]
-h, --help help for dump
-o, --output string output format. One of: yaml, json (default "yaml")
--private-key string private key to use for SSH acccess to instances (default "~/.ssh/id_rsa")
--ssh-user string the remote user for SSH access to instances (default "ubuntu")
```

### Options inherited from parent commands
Expand Down

0 comments on commit 6afbfe1

Please sign in to comment.