@@ -10,6 +10,7 @@ import (
1010 "github.com/smallstep/certificates/ca"
1111 "github.com/smallstep/cli/flags"
1212 "github.com/smallstep/cli/internal/sshutil"
13+ "github.com/smallstep/cli/utils"
1314 "github.com/smallstep/cli/utils/cautils"
1415 "github.com/urfave/cli"
1516 "go.step.sm/cli-utils/command"
@@ -27,9 +28,10 @@ func loginCommand() cli.Command {
2728 UsageText : `**step ssh login** [<identity>]
2829[**--token**=<token>] [**--provisioner**=<name>] [**--provisioner-password-file**=<file>]
2930[**--principal**=<string>] [**--not-before**=<time|duration>] [**--not-after**=<time|duration>]
30- [**--set**=<key=value>] [**--set-file**=<file>] [**--force**]
31+ [**--set**=<key=value>] [**--set-file**=<file>] [**--force**] [**--insecure**]
3132[**--offline**] [**--ca-config**=<file>]
32- [**--ca-url**=<uri>] [**--root**=<file>] [**--context**=<name>]` ,
33+ [**--ca-url**=<uri>] [**--root**=<file>] [**--context**=<name>]
34+ [**--kty**=<key-type>] [**--curve**=<curve>] [**--size**=<size>]` ,
3335 Description : `**step ssh login** generates a new SSH key pair and send a request to [step
3436certificates](https://github.com/smallstep/certificates) to sign a user
3537certificate. This certificate will be automatically added to the SSH agent.
@@ -64,6 +66,17 @@ $ step ssh login --not-after 1h alice
6466Request a new SSH certificate with multiple principals:
6567'''
6668$ step ssh login --principal admin --principal bob bob@smallstep.com
69+ '''
70+
71+ Request a new SSH certificate with an EC key and P-521 curve:
72+ '''
73+ $ step ssh certificate --kty EC --curve "P-521" mariano@work id_ecdsa
74+ '''
75+
76+ Request a new SSH certificate with an Octet Key Pair and Ed25519 curve:
77+
78+ '''
79+ $ step ssh certificate --kty OKP --curve Ed25519 mariano@work id_ed25519
6780'''` ,
6881 Flags : []cli.Flag {
6982 flags .Token ,
@@ -82,6 +95,10 @@ $ step ssh login --principal admin --principal bob bob@smallstep.com
8295 flags .CaURL ,
8396 flags .Root ,
8497 flags .Context ,
98+ flags .KTY ,
99+ flags .Curve ,
100+ flags .Size ,
101+ flags .Insecure ,
85102 },
86103 }
87104}
@@ -106,6 +123,7 @@ func loginAction(ctx *cli.Context) error {
106123 token := ctx .String ("token" )
107124 isAddUser := ctx .Bool ("add-user" )
108125 force := ctx .Bool ("force" )
126+ insecure := ctx .Bool ("insecure" )
109127 validAfter , validBefore , err := flags .ParseTimeDuration (ctx )
110128 if err != nil {
111129 return err
@@ -115,6 +133,11 @@ func loginAction(ctx *cli.Context) error {
115133 return err
116134 }
117135
136+ kty , curve , size , err := utils .GetKeyDetailsFromCLI (ctx , insecure , "kty" , "curve" , "size" )
137+ if err != nil {
138+ return err
139+ }
140+
118141 // Connect to the SSH agent.
119142 // step ssh login requires an ssh agent.
120143 agent , err := sshutil .DialAgent ()
@@ -169,8 +192,7 @@ func loginAction(ctx *cli.Context) error {
169192 return err
170193 }
171194
172- // Generate keypair
173- pub , priv , err := keyutil .GenerateDefaultKeyPair ()
195+ pub , priv , err := keyutil .GenerateKeyPair (kty , curve , size )
174196 if err != nil {
175197 return err
176198 }
@@ -184,7 +206,7 @@ func loginAction(ctx *cli.Context) error {
184206 var sshAuPubBytes []byte
185207 var auPub , auPriv interface {}
186208 if isAddUser {
187- auPub , auPriv , err = keyutil .GenerateDefaultKeyPair ( )
209+ auPub , auPriv , err = keyutil .GenerateKeyPair ( kty , curve , size )
188210 if err != nil {
189211 return err
190212 }
0 commit comments