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 1692201
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 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
10 changes: 3 additions & 7 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 Down Expand Up @@ -52,14 +48,14 @@ func Add() *cobra.Command {
providerName, _ := cmd.Flags().GetString("provider")
bucket, _ := cmd.Flags().GetString("bucket")

publicKey, err := readFile(publicKeyFileName)
privateKey, err := readFile(privateKeyFileName)
if err != nil {
return err
}

privateKey, err := readFile(privateKeyFileName)
publicKey, err := readFile(publicKeyFileName)
if err != nil {
return err
publicKey = privateKey + ".pub"
}

item := provider.Item{
Expand Down

0 comments on commit 1692201

Please sign in to comment.