@@ -28,10 +28,10 @@ func loginCommand() cli.Command {
28
28
UsageText : `**step ssh login** [<identity>]
29
29
[**--token**=<token>] [**--provisioner**=<name>] [**--provisioner-password-file**=<file>]
30
30
[**--principal**=<string>] [**--not-before**=<time|duration>] [**--not-after**=<time|duration>]
31
+ [**--kty**=<key-type>] [**--curve**=<curve>] [**--size**=<size>] [**--comment**=<comment>]
31
32
[**--set**=<key=value>] [**--set-file**=<file>] [**--force**] [**--insecure**]
32
33
[**--offline**] [**--ca-config**=<file>]
33
- [**--ca-url**=<uri>] [**--root**=<file>] [**--context**=<name>]
34
- [**--kty**=<key-type>] [**--curve**=<curve>] [**--size**=<size>]` ,
34
+ [**--ca-url**=<uri>] [**--root**=<file>] [**--context**=<name>]` ,
35
35
Description : `**step ssh login** generates a new SSH key pair and send a request to [step
36
36
certificates](https://github.com/smallstep/certificates) to sign a user
37
37
certificate. This certificate will be automatically added to the SSH agent.
@@ -68,13 +68,17 @@ Request a new SSH certificate with multiple principals:
68
68
$ step ssh login --principal admin --principal bob [email protected]
69
69
'''
70
70
71
+ Request a new SSH certificate and set a custom comment in the agent
72
+ '''
73
+ $ step ssh login --comment my-custom-comment [email protected]
74
+ '''
75
+
71
76
Request a new SSH certificate with an EC key and P-521 curve:
72
77
'''
73
78
$ step ssh certificate --kty EC --curve "P-521" mariano@work id_ecdsa
74
79
'''
75
80
76
81
Request a new SSH certificate with an Octet Key Pair and Ed25519 curve:
77
-
78
82
'''
79
83
$ step ssh certificate --kty OKP --curve Ed25519 mariano@work id_ed25519
80
84
'''` ,
@@ -95,6 +99,7 @@ $ step ssh certificate --kty OKP --curve Ed25519 mariano@work id_ed25519
95
99
flags .CaURL ,
96
100
flags .Root ,
97
101
flags .Context ,
102
+ flags .Comment ,
98
103
flags .KTY ,
99
104
flags .Curve ,
100
105
flags .Size ,
@@ -119,6 +124,11 @@ func loginAction(ctx *cli.Context) error {
119
124
principals = []string {subject }
120
125
}
121
126
127
+ comment := ctx .String ("comment" )
128
+ if comment == "" {
129
+ comment = subject
130
+ }
131
+
122
132
// Flags
123
133
token := ctx .String ("token" )
124
134
isAddUser := ctx .Bool ("add-user" )
@@ -163,7 +173,7 @@ func loginAction(ctx *cli.Context) error {
163
173
}
164
174
165
175
// Just return if key is present
166
- if key , err := agent .GetKey (subject , opts ... ); err == nil {
176
+ if key , err := agent .GetKey (comment , opts ... ); err == nil {
167
177
ui .Printf ("The key %s is already present in the SSH agent.\n " , key .String ())
168
178
return nil
169
179
}
@@ -270,15 +280,15 @@ func loginAction(ctx *cli.Context) error {
270
280
}
271
281
272
282
// Attempt to add key to agent if private key defined.
273
- if err := agent .AddCertificate (subject , resp .Certificate .Certificate , priv ); err != nil {
283
+ if err := agent .AddCertificate (comment , resp .Certificate .Certificate , priv ); err != nil {
274
284
ui .Printf (`{{ "%s" | red }} {{ "SSH Agent:" | bold }} %v` + "\n " , ui .IconBad , err )
275
285
} else {
276
286
ui .PrintSelected ("SSH Agent" , "yes" )
277
287
}
278
288
if isAddUser {
279
289
if resp .AddUserCertificate == nil {
280
290
ui .Printf (`{{ "%s" | red }} {{ "Add User Certificate:" | bold }} failed to create a provisioner certificate` + "\n " , ui .IconBad )
281
- } else if err := agent .AddCertificate (subject , resp .AddUserCertificate .Certificate , auPriv ); err != nil {
291
+ } else if err := agent .AddCertificate (comment , resp .AddUserCertificate .Certificate , auPriv ); err != nil {
282
292
ui .Printf (`{{ "%s" | red }} {{ "Add User Certificate:" | bold }} %v` + "\n " , ui .IconBad , err )
283
293
} else {
284
294
ui .PrintSelected ("Add User Certificate" , "yes" )
0 commit comments