Added: Ssh CLI command and API, config lease impl, sshConnect path to backend, http handler for Ssh connect

This commit is contained in:
Vishal Nayak
2015-06-17 12:39:49 -04:00
parent 647f3a59d9
commit fb866f9059
8 changed files with 219 additions and 0 deletions

49
command/ssh.go Normal file
View File

@@ -0,0 +1,49 @@
package command
import (
"fmt"
"log"
"strings"
)
type SshCommand struct {
Meta
}
func (c *SshCommand) Run(args []string) int {
log.Printf("Vishal: SshCommand.Run: args:%#v len(args):%d\n", args, len(args))
flags := c.Meta.FlagSet("ssh", FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil {
return 1
}
client, err := c.Client()
if err != nil {
c.Ui.Error(fmt.Sprintf("Error initializing client: %s", err))
return 2
}
//if len(args) < 3, fail
log.Printf("Vishal: sshCommand.Run: args[0]: %#v\n", args[0])
sshOneTimeKey, err := client.Sys().Ssh(args[0])
if err != nil {
c.Ui.Error(fmt.Sprintf("Error getting one-time-key for establishing SSH session", err))
return 2
}
log.Printf("Vishal: client.Sys().Ssh() returned! OTK:%#v\n", sshOneTimeKey)
//if sshOneTimeKey is empty, fail
//Establish a session directly from client to the target using the one time key received without making the vault server the middle guy:w
return 0
}
func (c *SshCommand) Synopsis() string {
return "Initiate a SSH session"
}
func (c *SshCommand) Help() string {
helpText := `
SshCommand Help String
`
return strings.TrimSpace(helpText)
}