Add username to SSH as well (#441)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-09-25 12:26:16 -04:00
1 parent 61a0ae02c1
commit b60e356b6c
1 file changed
+18 -7
+18 -7
View File
@@ -66,13 +66,13 @@ type Command struct {
flagTargetId string
flagHostId string
flagExec string
flagUsername string
// SSH
flagSshStyle string
// Postgres
flagPostgresStyle string
flagPostgresUsername string
flagPostgresStyle string
// RDP
flagRdpStyle string
@@ -221,6 +221,14 @@ func (c *Command) Flags() *base.FlagSets {
Usage: `Specifies how the CLI will attempt to invoke an SSH client. This will also set a suitable default for -exec if a value was not specified. Currently-understood values are "ssh" and "putty".`,
})
f.StringVar(&base.StringVar{
Name: "username",
Target: &c.flagUsername,
EnvVar: "BOUNDARY_CONNECT_USERNAME",
Completion: complete.PredictNothing,
Usage: `Specifies the username to pass through to the client`,
})
case "postgres":
f := set.NewFlagSet("Postgres Options")
@@ -235,10 +243,10 @@ func (c *Command) Flags() *base.FlagSets {
f.StringVar(&base.StringVar{
Name: "username",
Target: &c.flagPostgresUsername,
EnvVar: "BOUNDARY_CONNECT_POSTGRES_USERNAME",
Target: &c.flagUsername,
EnvVar: "BOUNDARY_CONNECT_USERNAME",
Completion: complete.PredictNothing,
Usage: `Specifies the username to pass through to the Postgres client.`,
Usage: `Specifies the username to pass through to the client`,
})
case "rdp":
@@ -726,13 +734,16 @@ func (c *Command) handleExec(passthroughArgs []string) {
case "putty":
args = append(args, "-P", port, ip)
}
if c.flagUsername != "" {
args = append(args, "-l", c.flagUsername)
}
case "postgres":
switch c.flagPostgresStyle {
case "psql":
args = append(args, "-p", port, "-h", ip)
if c.flagPostgresUsername != "" {
args = append(args, "-U", c.flagPostgresUsername)
if c.flagUsername != "" {
args = append(args, "-U", c.flagUsername)
}
}