Add support for authentication via ssh certificates and pub/privatekey #442

Merged
6543 merged 11 commits from 42wim/tea:sshcert into main 2022-09-14 19:00:09 +00:00
Showing only changes of commit d6d76ad4cd - Show all commits

@ -52,25 +52,20 @@ var CmdLoginAdd = cli.Command{
&cli.StringFlag{ &cli.StringFlag{
Name: "ssh-key", Name: "ssh-key",
Aliases: []string{"s"}, Aliases: []string{"s"},
Usage: "Path to a SSH key to use, overrides auto-discovery", Usage: "Path to a SSH key/certificate to use, overrides auto-discovery",
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "insecure", Name: "insecure",
Aliases: []string{"i"}, Aliases: []string{"i"},
Usage: "Disable TLS verification", Usage: "Disable TLS verification",
}, },
&cli.BoolFlag{
Name: "ssh-certificate",
Aliases: []string{"c"},
Usage: "Use SSH certificate to login (needs a running ssh-agent with certificate loaded)",
},
&cli.StringFlag{ &cli.StringFlag{
Name: "ssh-certificate-principal", Name: "ssh-agent-principal",
Aliases: []string{"p"}, Aliases: []string{"c"},
Usage: "Use SSH certificate with specified principal to login (needs a running ssh-agent with certificate loaded)\nIf not specified first found principal will be used", Usage: "Use SSH certificate with specified principal to login (needs a running ssh-agent with certificate loaded)\nIf not specified first found principal will be used",
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "ssh-key-agent-public-key", Name: "ssh-agent-key",
Aliases: []string{"a"}, Aliases: []string{"a"},
Usage: "Use SSH public key or SSH fingerprint to login (needs a running ssh-agent with ssh key loaded)", Usage: "Use SSH public key or SSH fingerprint to login (needs a running ssh-agent with ssh key loaded)",
}, },
@ -84,9 +79,9 @@ func runLoginAdd(ctx *cli.Context) error {
return interact.CreateLogin() return interact.CreateLogin()
} }
sshKeyAgent := false sshAgent := false
if ctx.String("ssh-key-agent-public-key") != "" { if ctx.String("ssh-agent-key") != "" || ctx.String("ssh-agent-principal") != "" {
sshKeyAgent = true sshAgent = true
} }
// else use args to add login // else use args to add login
@ -97,8 +92,8 @@ func runLoginAdd(ctx *cli.Context) error {
ctx.String("password"), ctx.String("password"),
ctx.String("ssh-key"), ctx.String("ssh-key"),
ctx.String("url"), ctx.String("url"),
ctx.String("ssh-certificate-principal"), ctx.String("ssh-agent-principal"),
ctx.String("ssh-key-agent-public-key"), ctx.String("ssh-agent-key"),
ctx.Bool("insecure"), ctx.Bool("insecure"),
sshKeyAgent) sshAgent)
} }