forked from gopasspw/gopass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
1261 lines (1257 loc) · 40.4 KB
/
commands.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package main
import (
"context"
"fmt"
ap "github.com/gopasspw/gopass/pkg/action"
"github.com/gopasspw/gopass/pkg/action/binary"
"github.com/gopasspw/gopass/pkg/action/create"
"github.com/gopasspw/gopass/pkg/action/xc"
"github.com/gopasspw/gopass/pkg/agent"
"github.com/gopasspw/gopass/pkg/agent/client"
"github.com/gopasspw/gopass/pkg/config"
"github.com/gopasspw/gopass/pkg/ctxutil"
"github.com/urfave/cli"
)
func getCommands(ctx context.Context, action *ap.Action, app *cli.App) []cli.Command {
return []cli.Command{
{
Name: "agent",
Usage: "Start gopass-agent",
Description: "" +
"This command starts the gopass agent that will cache passphrases " +
"so they don't have to be entered repeatedly.",
Action: func(c *cli.Context) error {
ec := make(chan error)
go func() {
ec <- agent.New(config.Directory()).ListenAndServe(ctx)
}()
select {
case <-ctx.Done():
return fmt.Errorf("aborted")
case e := <-ec:
return e
}
},
Subcommands: []cli.Command{
{
Name: "client",
Usage: "Start a simple agent test client",
Hidden: true,
Action: func(c *cli.Context) error {
pw, err := client.New(config.Directory()).Passphrase(ctx, "test", "test")
if err != nil {
return err
}
fmt.Println("Passphrase:" + pw)
return nil
},
},
},
},
{
Name: "audit",
Usage: "Scan for weak passwords",
Description: "" +
"This command decrypts all secrets and checks for common flaws and (optionally) " +
"against a list of previously leaked passwords.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Audit(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.IntFlag{
Name: "jobs, j",
Usage: "The number of jobs to run concurrently when auditing",
Value: 1,
},
},
Subcommands: []cli.Command{
{
Name: "hibp",
Usage: "Detect leaked passwords",
Description: "" +
"This command will decrypt all secrets and check the passwords against the public " +
"havibeenpwned.com v2 API or dumps. " +
"To use the dumps you need to download the dumps from https://haveibeenpwned.com/passwords first. Be sure to grab the one that says '(ordered by hash)'. " +
"This is a very expensive operation, for advanced users. " +
"Most users should probably use the API. " +
"If you want to use the dumps you need to use 7z to extract the dump: 7z x pwned-passwords-ordered-2.0.txt.7z.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.HIBP(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.BoolFlag{
Name: "force, f",
Usage: "Force to move the secret and overwrite existing one",
},
cli.BoolFlag{
Name: "api, a",
Usage: "Use HIBP API",
},
cli.StringSliceFlag{
Name: "dumps",
Usage: "One or more HIBP v1/v2 dumps",
},
},
},
},
},
{
Name: "binary",
Usage: "Assist with Binary/Base64 content",
Description: "" +
"These commands directly convert binary files from/to base64 encoding.",
Aliases: []string{"bin"},
Subcommands: []cli.Command{
{
Name: "cat",
Usage: "Print content of a secret to stdout, or insert from stdin",
Description: "" +
"This command is similar to the way cat works on the command line. " +
"It can either be used to retrieve the decoded content of a secret " +
"similar to 'cat file' or vice versa to encode the content from STDIN " +
"to a secret.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return binary.Cat(withGlobalFlags(ctx, c), c, action.Store)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
},
{
Name: "sum",
Usage: "Compute the SHA256 checksum",
Description: "" +
"This command decodes an Base64 encoded secret and computes the SHA256 checksum " +
"over the decoded data. This is useful to verify the integrity of an " +
"inserted secret.",
Aliases: []string{"sha", "sha256"},
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return binary.Sum(withGlobalFlags(ctx, c), c, action.Store)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
},
{
Name: "copy",
Usage: "Copy files from or to the password store",
Description: "" +
"This command either reads a file from the filesystem and writes the " +
"encoded and encrypted version in the store or it decrypts and decodes " +
"a secret and writes the result to a file. Either source or destination " +
"must be a file and the other one a secret. If you want the source to " +
"be securely removed after copying, use 'gopass binary move'",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Aliases: []string{"cp"},
Action: func(c *cli.Context) error {
return binary.Copy(withGlobalFlags(ctx, c), c, action.Store)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "force, f",
Usage: "Force to move the secret and overwrite existing one",
},
},
},
{
Name: "move",
Usage: "Move files from or to the password store",
Description: "" +
"This command either reads a file from the filesystem and writes the " +
"encoded and encrypted version in the store or it decrypts and decodes " +
"a secret and writes the result to a file. Either source or destination " +
"must be a file and the other one a secret. The source will be wiped " +
"from disk or from the store after it has been copied successfully " +
"and validated. If you don't want the source to be removed use " +
"'gopass binary copy'",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Aliases: []string{"mv"},
Action: func(c *cli.Context) error {
return binary.Move(withGlobalFlags(ctx, c), c, action.Store)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "force, f",
Usage: "Force to move the secret and overwrite existing one",
},
},
},
},
},
{
Name: "clone",
Usage: "Clone a store from git",
Description: "" +
"This command clones an existing password store from a git remote to " +
"a local password store. Can be either used to initialize a new root store " +
"or to add a new mounted sub-store." +
"" +
"Needs at least one argument (git URL) to clone from. " +
"Accepts a second argument (mount location) to clone and mount a sub-store, e.g. " +
"'gopass clone [email protected]/store.git foo/bar'",
Action: func(c *cli.Context) error {
return action.Clone(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "path",
Usage: "Path to clone the repo to",
},
cli.StringFlag{
Name: "crypto",
Usage: "Select crypto backend (gpg, gpgcli, plain, xc)",
},
cli.StringFlag{
Name: "sync",
Usage: "Select sync backend (git, gitcli, gogit, noop)",
},
},
},
{
Name: "completion",
Usage: "Bash and ZSH completion",
Description: "" +
"Source the output of this command with bash or zsh to get auto completion",
Subcommands: []cli.Command{{
Name: "bash",
Usage: "Source for auto completion in bash",
Action: action.CompletionBash,
}, {
Name: "zsh",
Usage: "Source for auto completion in zsh",
Action: func(c *cli.Context) error {
return action.CompletionZSH(c, app)
},
}, {
Name: "fish",
Usage: "Source for auto completion in fish",
Action: func(c *cli.Context) error {
return action.CompletionFish(c, app)
},
}, {
Name: "openbsdksh",
Usage: "Source for auto completion in OpenBSD's ksh",
Action: func(c *cli.Context) error {
return action.CompletionOpenBSDKsh(c, app)
},
}},
},
{
Name: "config",
Usage: "Edit configuration",
Description: "" +
"This command allows for easy printing and editing of the configuration. " +
"Without argument, the entire config is printed. " +
"With a single argument, a single key can be printed. " +
"With two arguments a setting specified by key can be set to value.",
Action: func(c *cli.Context) error {
return action.Config(withGlobalFlags(ctx, c), c)
},
BashComplete: action.ConfigComplete,
Flags: []cli.Flag{
cli.StringFlag{
Name: "store",
Usage: "Set value to substore config",
},
},
},
{
Name: "copy",
Aliases: []string{"cp"},
Usage: "Copy secrets from one location to another",
Description: "" +
"This command copies an existing secret in the store to another location. " +
"This also works across different sub-stores. If the source is a directory it will " +
"automatically copy recursively. In that case, the source directory is re-created " +
"at the destination if no trailing slash is found, otherwise the contents are " +
"flattened (similar to rsync).",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Copy(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "force, f",
Usage: "Force to copy the secret and overwrite existing one",
},
},
},
{
Name: "create",
Aliases: []string{"new"},
Usage: "Easy creation of new secrets",
Description: "" +
"This command starts a wizard to aid in creation of new secrets.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return create.Create(withGlobalFlags(ctx, c), c, action.Store)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "store, s",
Usage: "Which store to use",
},
},
},
{
Name: "delete",
Usage: "Remove secrets",
Description: "" +
"This command removes secrets. It can work recursively on folders. " +
"Recursing across stores is purposefully not supported.",
Aliases: []string{"remove", "rm"},
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Delete(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "recursive, r",
Usage: "Recursive delete files and folders",
},
cli.BoolFlag{
Name: "force, f",
Usage: "Force to delete the secret",
},
},
},
{
Name: "edit",
Usage: "Edit new or existing secrets",
Description: "" +
"Use this command to insert a new secret or edit an existing one using " +
"your $EDITOR. It will attempt to create a secure temporary directory " +
"for storing your secret while the editor is accessing it. Please make " +
"sure your editor doesn't leak sensitive data to other locations while " +
"editing.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Edit(withGlobalFlags(ctx, c), c)
},
Aliases: []string{"set"},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.StringFlag{
Name: "editor, e",
Usage: "Use this editor binary",
},
cli.BoolFlag{
Name: "create, c",
Usage: "Create a new secret if none found",
},
},
},
{
Name: "find",
Usage: "Search for secrets",
Description: "" +
"This command will first attempt a simple pattern match on the name of the " +
"secret. If that yields no results, it will trigger a fuzzy search. " +
"If there is an exact match it will be shown directly; if there are " +
"multiple matches, a selection will be shown.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Find(withGlobalFlags(ctxutil.WithFuzzySearch(ctx, false), c), c)
},
Aliases: []string{"search"},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "clip, c",
Usage: "Copy the password into the clipboard",
},
},
},
{
Name: "fsck",
Usage: "Check store integrity",
Description: "" +
"Check the integrity of the given sub-store or all stores if none are specified. " +
"Will automatically fix all issues found.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Fsck(withGlobalFlags(ctx, c), c)
},
BashComplete: action.MountsComplete,
},
{
Name: "generate",
Usage: "Generate a new password",
Description: "" +
"Generate a new password of the specified length, optionally with no symbols. " +
"Alternatively, a xkcd style password can be generated (https://xkcd.com/936/). " +
"Optionally put it on the clipboard and clear clipboard after 45 seconds. " +
"Prompt before overwriting existing password unless forced. " +
"It will replace only the first line of an existing file with a new password.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Generate(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) { action.CompleteGenerate(ctx, c) },
Flags: []cli.Flag{
cli.BoolTFlag{
Name: "clip, c",
Usage: "Copy the generated password to the clipboard",
},
cli.BoolFlag{
Name: "print, p",
Usage: "Print the generated password to the terminal",
},
cli.BoolFlag{
Name: "force, f",
Usage: "Force to overwrite existing password",
},
cli.BoolFlag{
Name: "edit, e",
Usage: "Open secret for editing after generating a password",
},
cli.BoolFlag{
Name: "symbols, s",
Usage: "Use symbols in the password",
},
cli.BoolFlag{
Name: "xkcd, x",
Usage: "Use multiple random english words combined to a password. By default, space is used as separator and all words are lowercase",
},
cli.StringFlag{
Name: "xkcdsep, xs",
Usage: "Word separator for generated xkcd style password. If no separator is specified, the words are combined without spaces/separator and the first character of words is capitalised. This flag implies -xkcd",
Value: "",
},
cli.StringFlag{
Name: "xkcdlang, xl",
Usage: "Language to generate password from, currently de (german) and en (english, default) are supported",
Value: "en",
},
},
},
{
Name: "git-credential",
Usage: `Use "!gopass git-credential $@" as git's credential.helper`,
Description: "" +
"This command allows you to cache your git-credentials with gopass." +
"Activate by using `git config --global credential.helper \"!gopass git-credential $@\"`",
Subcommands: []cli.Command{
{
Name: "get",
Hidden: true,
Action: func(c *cli.Context) error {
return action.GitCredentialGet(withGlobalFlags(ctx, c), c)
},
Before: func(c *cli.Context) error {
return action.GitCredentialBefore(ctxutil.WithInteractive(withGlobalFlags(ctx, c), false), c)
},
},
{
Name: "store",
Hidden: true,
Action: func(c *cli.Context) error {
return action.GitCredentialStore(withGlobalFlags(ctx, c), c)
},
Before: func(c *cli.Context) error {
return action.GitCredentialBefore(ctxutil.WithInteractive(withGlobalFlags(ctx, c), false), c)
},
},
{
Name: "erase",
Hidden: true,
Action: func(c *cli.Context) error {
return action.GitCredentialErase(withGlobalFlags(ctx, c), c)
},
Before: func(c *cli.Context) error {
return action.GitCredentialBefore(ctxutil.WithInteractive(withGlobalFlags(ctx, c), false), c)
},
},
{
Name: "configure",
Description: "This command configures gopass as git's credential.helper",
Action: func(c *cli.Context) error {
return action.GitCredentialConfigure(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.BoolFlag{
Name: "global",
Usage: "Install for current user",
},
cli.BoolFlag{
Name: "local",
Usage: "Install for current repository only",
},
cli.BoolFlag{
Name: "system",
Usage: "Install for all users, requires superuser rights",
},
},
},
},
},
{
Name: "jsonapi",
Usage: "Run and configure gopass as jsonapi e.g. for browser plugins",
Description: "Setup and run gopass as native messaging hosts, e.g. for browser plugins.",
Hidden: false,
Subcommands: []cli.Command{
{
Name: "listen",
Usage: "Listen and respond to messages via stdin/stdout",
Description: "Gopass is started in listen mode from browser plugins using a wrapper specified in native messaging host manifests",
Action: func(c *cli.Context) error {
return action.JSONAPI(withGlobalFlags(ctx, c), c)
},
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
},
{
Name: "configure",
Usage: "Setup gopass native messaging manifest for selected browser",
Description: "To access gopass from browser plugins, a native app manifest must be installed at the correct location",
Action: func(c *cli.Context) error {
return action.SetupNativeMessaging(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "browser",
Usage: "One of 'chrome' and 'firefox'",
},
cli.StringFlag{
Name: "path",
Usage: "Path to install 'gopass_wrapper.sh' to",
},
cli.StringFlag{
Name: "manifest-path",
Usage: "Path to install 'com.justwatch.gopass.json' to",
},
cli.BoolFlag{
Name: "global",
Usage: "Install for all users, requires superuser rights",
},
cli.StringFlag{
Name: "libpath",
Usage: "Library path for global installation on linux. Default is /usr/lib",
},
cli.StringFlag{
Name: "gopass-path",
Usage: "Path to gopass binary. Default is auto detected",
},
cli.BoolTFlag{
Name: "print",
Usage: "Print installation summary before creating any files",
},
},
},
},
},
{
Name: "otp",
Usage: "Generate time- or hmac-based tokens",
Aliases: []string{"totp", "hotp"},
Description: "" +
"Tries to parse an OTP URL (otpauth://). URL can be TOTP or HOTP. " +
"The URL can be provided on its own line or on a key value line with a key named 'totp'.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.OTP(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "clip, c",
Usage: "Copy the time-based token into the clipboard",
},
cli.StringFlag{
Name: "qr, q",
Usage: "Write QR code to FILE",
},
cli.BoolFlag{
Name: "password, o",
Usage: "Only display the token",
},
},
},
{
Name: "git",
Usage: "Run a git command inside a password store (init, remote, push, pull)",
Description: "" +
"If the password store is a git repository, execute a git command " +
"specified by git-command-args.",
Subcommands: []cli.Command{
{
Name: "init",
Usage: "Init git repo",
Description: "Create and initialize a new git repo in the store",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.GitInit(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "store",
Usage: "Store to operate on",
},
cli.StringFlag{
Name: "sign-key",
Usage: "GPG Key to sign commits",
},
cli.StringFlag{
Name: "rcs",
Usage: "Select sync backend (git, gitcli, gogit, noop)",
},
},
},
{
Name: "remote",
Usage: "Manage git remotes",
Description: "These subcommands can be used to manage git remotes",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Subcommands: []cli.Command{
{
Name: "add",
Usage: "Add git remote",
Description: "Add a new git remote",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.GitAddRemote(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "store",
Usage: "Store to operate on",
},
},
},
{
Name: "remove",
Usage: "Remove git remote",
Description: "Remove a git remote",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.GitRemoveRemote(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "store",
Usage: "Store to operate on",
},
},
},
},
},
{
Name: "push",
Usage: "Push to remote",
Description: "Push to a git remote",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.GitPush(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "store",
Usage: "Store to operate on",
},
},
},
{
Name: "pull",
Usage: "Pull from remote",
Description: "Pull from a git remote",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.GitPull(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "store",
Usage: "Store to operate on",
},
},
},
},
},
{
Name: "grep",
Usage: "Search for secrets files containing search-string when decrypted.",
Description: "" +
"This command decrypts all secrets and performs a pattern matching on the " +
"content.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Grep(withGlobalFlags(ctx, c), c)
},
},
{
Name: "history",
Usage: "Show password history",
Aliases: []string{"hist"},
Description: "" +
"Display the change history for a secret",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.History(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "password, p",
Usage: "Include passwords in output",
},
},
},
{
Name: "init",
Usage: "Initialize new password store.",
Description: "" +
"Initialize new password storage and use gpg-id for encryption.",
Action: func(c *cli.Context) error {
return action.Init(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "path, p",
Usage: "Set the sub-store path to operate on",
},
cli.StringFlag{
Name: "store, s",
Usage: "Set the name of the sub-store",
},
cli.StringFlag{
Name: "crypto",
Usage: "Select crypto backend (gpg, gpgcli, plain, xc)",
},
cli.StringFlag{
Name: "rcs",
Usage: "Select sync backend (git, gitcli, gogit, noop)",
},
cli.BoolFlag{
Name: "nogit",
Usage: "(DEPRECATED): Select noop RCS backend. Use '--rcs noop' instead",
Hidden: true,
},
},
},
{
Name: "insert",
Usage: "Insert a new secret",
Description: "" +
"Insert a new secret. Optionally, echo the secret back to the console during entry. " +
"Or, optionally, the entry may be multiline. " +
"Prompt before overwriting existing secret unless forced.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Insert(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "echo, e",
Usage: "Display secret while typing",
},
cli.BoolFlag{
Name: "multiline, m",
Usage: "Insert using $EDITOR",
},
cli.BoolFlag{
Name: "force, f",
Usage: "Overwrite any existing secret and do not prompt to confirm recipients",
},
cli.BoolFlag{
Name: "append, a",
Usage: "Append to any existing data",
},
},
},
{
Name: "list",
Usage: "List existing secrets",
Description: "" +
"This command will list all existing secrets. Provide a folder prefix to list " +
"only certain subfolders of the store.",
Aliases: []string{"ls"},
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.List(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.IntFlag{
Name: "limit, l",
Usage: "Max tree depth",
},
cli.BoolFlag{
Name: "flat, f",
Usage: "Print flat list",
},
cli.BoolFlag{
Name: "folders, fo",
Usage: "Print flat list of folders",
},
cli.BoolFlag{
Name: "strip-prefix, s",
Usage: "Strip prefix from filtered entries",
},
},
},
{
Name: "move",
Aliases: []string{"mv"},
Usage: "Move secrets from one location to another",
Description: "" +
"This command moves a secret from one path to another. This also works " +
"across different sub-stores. If the source is a directory, the source directory " +
"is re-created at the destination if no trailing slash is found, otherwise the " +
"contents are flattened (similar to rsync).",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Move(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "force, f",
Usage: "Force to move the secret and overwrite existing one",
},
},
},
{
Name: "mounts",
Usage: "Edit mounted stores",
Description: "" +
"This command displays all mounted password stores. It offers several " +
"subcommands to create or remove mounts.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.MountsPrint(withGlobalFlags(ctx, c), c)
},
Subcommands: []cli.Command{
{
Name: "add",
Aliases: []string{"mount"},
Usage: "Mount a password store",
Description: "" +
"This command allows for mounting an existing or new password store " +
"at any path in an existing root store.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.MountAdd(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "init, i",
Usage: "Init the store with the given recipient key",
},
},
},
{
Name: "remove",
Aliases: []string{"rm", "unmount", "umount"},
Usage: "Umount an mounted password store",
Description: "" +
"This command allows to unmount an mounted password store. This will " +
"only updated the configuration and not delete the password store.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.MountRemove(withGlobalFlags(ctx, c), c)
},
BashComplete: action.MountsComplete,
},
},
},
{
Name: "recipients",
Usage: "Edit recipient permissions",
Description: "" +
"This command displays all existing recipients for all mounted stores. " +
"The subcommands allow adding or removing recipients.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.RecipientsPrint(withGlobalFlags(ctx, c), c)
},
Subcommands: []cli.Command{
{
Name: "add",
Aliases: []string{"authorize"},
Usage: "Add any number of Recipients to any store",
Description: "" +
"This command adds any number of recipients to any existing store. " +
"If none are given it will display a list of usable public keys. " +
"After adding the recipient to the list it will re-encrypt the whole " +
"affected store to make sure the recipient has access to all existing " +
"secrets.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.RecipientsAdd(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "store",
Usage: "Store to operate on",
},
cli.BoolFlag{
Name: "force",
Usage: "Force adding non-existing keys",
},
},
},
{
Name: "remove",
Aliases: []string{"rm", "deauthorize"},
Usage: "Remove any number of Recipients from any store",
Description: "" +
"This command removes any number of recipients from any existing store. " +
"If no recipients are provided, it will show a list of existing recipients " +
"to choose from. It will refuse to remove the current user's key from the " +
"store to avoid losing access. After removing the keys it will re-encrypt " +
"all existing secrets. Please note that the removed recipients will still " +
"be able to decrypt old revisions of the password store and any local " +
"copies they might have. The only way to reliably remove a recipient is to " +
"rotate all existing secrets.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.RecipientsRemove(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) {
action.RecipientsComplete(ctx, c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "store",
Usage: "Store to operate on",
},
cli.BoolFlag{
Name: "force",
Usage: "Force adding non-existing keys",
},
},
},
{
Name: "update",
Usage: "Recompute the saved recipient list checksums",
Description: "" +
"This command will recompute the saved recipient checksum" +
"and save them to the config.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.RecipientsUpdate(withGlobalFlags(ctx, c), c)
},
},
},
},
{
Name: "setup",
Usage: "Initialize a new password store",
Description: "" +
"This command is automatically invoked if gopass is started without any " +
"existing password store. This command exists so users can be provided with " +
"simple one-command setup instructions.",
Hidden: true,
Action: func(c *cli.Context) error {
return action.InitOnboarding(withGlobalFlags(ctx, c), c)
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "remote",
Usage: "URL to a git remote, will attempt to join this team",
},
cli.StringFlag{
Name: "alias",
Usage: "Local mount point for the given remote",
},
cli.BoolFlag{
Name: "create",
Usage: "Create a new team (default: false, i.e. join an existing team)",
},
cli.StringFlag{
Name: "name",
Usage: "Firstname and Lastname for unattended GPG key generation",
},
cli.StringFlag{
Name: "email",
Usage: "EMail for unattended GPG key generation",
},
cli.StringFlag{
Name: "crypto",
Usage: "Select crypto backend (gpg, gpgcli, plain, xc)",
},
cli.StringFlag{
Name: "rcs",
Usage: "Select sync backend (git, gitcli, gogit, noop)",
},
},
},
{
Name: "show",
Usage: "Display a secret",
Description: "" +
"Show an existing secret and optionally put its first line on the clipboard. " +
"If put on the clipboard, it will be cleared after 45 seconds.",
Before: func(c *cli.Context) error { return action.Initialized(withGlobalFlags(ctx, c), c) },
Action: func(c *cli.Context) error {
return action.Show(withGlobalFlags(ctx, c), c)
},
BashComplete: func(c *cli.Context) { action.Complete(ctx, c) },
Flags: []cli.Flag{
cli.BoolFlag{
Name: "clip, c",