Skip to content

Commit

Permalink
feat(add): Default public key to <private key>.pub if not given
Browse files Browse the repository at this point in the history
  • Loading branch information
milkpirate committed Dec 7, 2022
1 parent f604333 commit c28f756
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,30 @@ Injects SSL keys to `ssh-agent` stored in 1Password, Bitwarden and AWS S3.

## How to use it

1. Login to Bitwarden or 1Password with `bw` or `op`. If you are using S3, set your credentials.
1. Login to Bitwarden (and export its session key) or 1Password with `bw` or `op`. If you are using S3, set your credentials.
1. Add your key pairs to your password manager.

> **NOTE:** If not public key is given, the private one, postfixed with `.pub`, will be used.
For 1Password
---

```shell
ssh-manager add --name my-another-server --private-key $PK_PATH --public-key $PUB_KEY_PATH --provider op
ssh-manager add --name my-another-server --private-key $PK_PATH [ --public-key $PUB_KEY_PATH ] --provider op
```

For Bitwarden
---

```shell
ssh-manager add --name my-server --private-key $PK_PATH --public-key $PUB_KEY_PATH --provider bw
ssh-manager add --name my-server --private-key $PK_PATH [ --public-key $PUB_KEY_PATH ] --provider bw
```

For AWS S3
---

```shell
ssh-manager add --name my-another-server --private-key $PK_PATH --public-key $PUB_KEY_PATH --provider s3 --bucket my-bucket
ssh-manager add --name my-another-server --private-key $PK_PATH [ --public-key $PUB_KEY_PATH ] --provider s3 --bucket my-bucket
```

## Improvements to be made
Expand Down
11 changes: 5 additions & 6 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ func setupAddCommand(cmd *cobra.Command) {

cmd.Flags().String("public-key", "", "Public Key file")

if err := cmd.MarkFlagRequired("public-key"); err != nil {
log.Fatalf("Lethal damage: %s\n\n", err)
}

cmd.Flags().String("private-key", "", "Private Key file")

if err := cmd.MarkFlagRequired("private-key"); err != nil {
Expand All @@ -47,10 +43,13 @@ func Add() *cobra.Command {
Short: "Add Manager key to given provider.",
RunE: func(cmd *cobra.Command, args []string) error {
name, _ := cmd.Flags().GetString("name")
publicKeyFileName, _ := cmd.Flags().GetString("public-key")
privateKeyFileName, _ := cmd.Flags().GetString("private-key")
providerName, _ := cmd.Flags().GetString("provider")
bucket, _ := cmd.Flags().GetString("bucket")
privateKeyFileName, _ := cmd.Flags().GetString("private-key")
publicKeyFileName, err := cmd.Flags().GetString("public-key")
if err != nil {
publicKeyFileName = privateKeyFileName + ".pub"
}

publicKey, err := readFile(publicKeyFileName)
if err != nil {
Expand Down

0 comments on commit c28f756

Please sign in to comment.