Skip to content

Commit

Permalink
add pass ssh 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Penninckx committed Jun 30, 2017
1 parent 08735cd commit d859f54
Show file tree
Hide file tree
Showing 6 changed files with 479 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
dist: trusty
sudo: false

language: bash

env:
- PASS_VERSION=1.7
- PASS_VERSION=master

addons:
apt:
sources:
- debian-sid
packages:
- shellcheck
- tree

before_script:
- wget https://git.zx2c4.com/password-store/snapshot/password-store-$PASS_VERSION.tar.xz
- tar -xvf password-store-$PASS_VERSION.tar.xz
- ln -s password-store-$PASS_VERSION/src/password-store.sh pass
- export PATH="$PATH:$PWD"

install: true

script:
- make lint
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 0.1

* Choose between rofi and fzf.
* By default pick rofi, fallback to fzf.
* If selected keyfile does not exist, generate a keypair with a passphrase stored in pass.
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
PROG ?= ssh
PREFIX ?= /usr
DESTDIR ?=
LIBDIR ?= $(PREFIX)/lib
SYSTEM_EXTENSION_DIR ?= $(LIBDIR)/password-store/extensions
MANDIR ?= $(PREFIX)/share/man

all:
@echo "pass-$(PROG) is a shell script and does not need compilation, it can be simply executed."
@echo ""
@echo "To install it try \"make install\" instead."
@echo
@echo "To run pass $(PROG) one needs to have some tools installed on the system:"
@echo " password store"

install:
@install -v -d "$(DESTDIR)$(MANDIR)/man1" && install -m 0644 -v pass-$(PROG).1 "$(DESTDIR)$(MANDIR)/man1/pass-$(PROG).1"
@install -v -d "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/"
@install -Dm0755 $(PROG).bash "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/$(PROG).bash"
@echo
@echo "pass-$(PROG) is installed succesfully"
@echo

uninstall:
@rm -vrf \
"$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/$(PROG).bash" \
"$(DESTDIR)$(MANDIR)/man1/pass-$(PROG).1" \

test:
make -C tests

lint:
shellcheck -s bash $(PROG).bash


.PHONY: install uninstall lint test
121 changes: 120 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,120 @@
# pass ssh
# pass ssh 0.1 [![build status][build-img]][build-url]

A [pass](https://www.passwordstore.org/) extension that lets you quickly
create ssh keypairs and output public keys using
[fzf](https://github.com/junegunn/fzf) or
[rofi](https://davedavenport.github.io/rofi/).


## Usage

```
pass ssh [--help,-h]
[--fzf,-f]|[--rofi,-r] [--ssh-dir <s>,-d <s>]
[--pass-prefix <s>,-p <s>] [--passphrase-no-symbols,-n] [--passphrase-length <s>,-l <s>]
[--ssh-t <s>] [--ssh-b <s>]
```

`pass-ssh` provides an interactive solution to create ssh private
and public keypairs with passphrases stored in `pass` as well as
write the public key to stdout. It will show all available ssh keys in
either `fzf` or `rofi`, wait for the user to select one and
write the public key to stdout.

The user can select `fzf` or `rofi` by giving either `--fzf`
or `--rofi`. By default, `rofi` will be selected and
`pass-ssh` will fallback to `fzf`.

If the selected key file does not exist under the directory given by
`--ssh-dir`, first a passphrase will be generated in `pass`
under the prefix given by `--pass-prefix`. Specific passphrase
length can be given using `--passphrase-length` and no symbols can
be activated with `--passphrase-no-symbols`. Second, a new private
and public keypair will be generated with the aforementioned passphrase
and with `ssh-keygen`'s `-t` and `-b` option given
respectively by `--ssh-t` and `--ssh-b`. Lastly, the public key
is written to stdout.

If the selected key exists, the public key is simply written to stdout.


## Options
* `-f`, `--fzf` Use fzf to select pass-name.
* `-r`, `--rofi` Use rofi to select pass-name.
* `-d`, `--ssh-dir` Directory holding ssh keyfiles, default $HOME/.ssh.
* `-p`, `--pass-prefix` Prefix under which passphrase are stored in pass, default sshkey-passphrase.
* `-n`, `--no-symbols` Do not use any non-alphanumeric characters.
* `-l <size>`, `--length=<size>` Provide a password length.
* `--ssh-t` ssh-keygen's -t option, the type of key to create.
* `--ssh-b` ssh-keygen's -b option, the number of bits in the key to create.
* `-h`, `--help` Show usage message.


## Examples

Combined with a clipboard manager like [`xclip`](https://github.com/astrand/xclip):
```
pass ssh | xclip -in -selection clipboard
```


## Installation


### ArchLinux

```sh
pacaur -S pass-ssh
```


### Other linuxes

```sh
git clone https://github.com/ibizaman/pass-ssh/
cd pass-ssh
sudo make install
```


### Requirements

* `pass 1.7.0` or greater.
* If you do not want to install this extension as system extension, you need to
enable user extension with `PASSWORD_STORE_ENABLE_EXTENSIONS=true pass`. You can
create an alias in `.bashrc`: `alias pass='PASSWORD_STORE_ENABLE_EXTENSIONS=true pass'`


## Contribution

Feedback, contributors, pull requests are all very welcome.


## Acknowledgments

Thanks to [roddhjav](https://github.com/roddhjav) for creating
[pass-update](https://github.com/roddhjav/pass-update) from which this
script is heavily inspired.


## License

```
Copyright (C) 2017 Pierre PENNINCKX
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
```

[build-img]: https://travis-ci.org/ibizaman/pass-ssh.svg?branch=master
[build-url]: https://travis-ci.org/ibizaman/pass-ssh
120 changes: 120 additions & 0 deletions pass-ssh.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
.TH pass-ssh 1 "June 2017" "pass-ssh"

.SH NAME
pass ssh - A \fBpass\fP(1) extension that lets you quickly create ssh
keypairs and output public keys using \fBfzf\fP(1) or \fBrofi\fP(1).

.SH SYNOPSIS
\fBpass ssh\fP [--help,-h]
[--fzf,-f]|[--rofi,-r] [--ssh-dir <s>,-d <s>]
[--pass-prefix <s>,-p <s>] [--passphrase-no-symbols,-n] [--passphrase-length <s>,-l <s>]
[--ssh-t <s>] [--ssh-b <s>]

.SH DESCRIPTION
\fBpass-ssh\fP Provide an interactive solution to create ssh private
and public keypairs with passphrases stored in \fIpass\fP as well as
write the public key to stdout. It will show all available ssh keys in
either \fIfzf\fP or \fIrofi\fP, wait for the user to select one and
write the public key to stdout.

The user can select \fIfzf\fP or \fIrofi\fP by giving either \fI--fzf\fP
or \fI--rofi\fP. By default, \fIrofi\fP will be selected and
\fBpass-ssh\fP will fallback to \fIfzf\fP.

If the selected key file does not exist under the directory given by
\fI--ssh-dir\fP, first a passphrase will be generated in \fBpass\fP
under the prefix given by \fI--pass-prefix\fP. Specific passphrase
length can be given using \fI--passphrase-length\fP and no symbols can
be activated with \fI--passphrase-no-symbols\fP. Second, a new private
and public keypair will be generated with the aforementioned passphrase
and with \fBssh-keygen\fP's \fI-t\fP and \fI-b\fP option given
respectively by \fI--ssh-t\fP and \fI--ssh-b\fP. Lastly, the public key
is written to stdout.

If the selected key exists, the public key is simply written to stdout.

.SH OPTIONS

.TP
\fB\-f\fB, \-\-fzf\fR
Use fzf to select pass-name.

.TP
\fB\-r\fB, \-\-rofi\fR
Use rofi to select pass-name.

.TP
\fB\-d\fB, \-\-ssh\-dir\fR
Directory holding ssh keyfiles, default $HOME/.ssh.

.TP
\fB\-p\fB, \-\-pass\-prefix\fR
Prefix under which passphrase are stored in pass, default
sshkey-passphrase.

.TP
\fB\-n\fB, \-\-no-symbols\fR
Do not use any non-alphanumeric characters.

.TP
\fB\-l <size>\fB, \-\-length=<size>\fR
Provide a password length.

.TP
\fB--ssh-t\fB\fR
ssh-keygen's -t option, the type of key to create.

.TP
\fB--ssh-b\fB\fR
ssh-keygen's -b option, the number of bits in the key to create.

.TP
\fB\-h\fB, \-\-help\fR
Show usage message.

.SH EXAMPLES
Combined with a clipboard manager like \fBxclip\fR:

.PP
.nf
.RS
pass ssh | xclip -in -selection clipboard
.RE
.fi
.PP


.SH SEE ALSO
.BR fzf(1),
.BR pass(1),
.BR rofi(1),
.BR ssh-keygen(1),
.BR xclip(1),

.SH AUTHORS
.B pass ssh
was written by
.MT ibizapeanut@gmail.com
Pierre PENNINCKX
.ME .

.SH ACKNOWLEDGMENTS
Thanks to
.B roddhjav
https://github.com/roddhjav for creating
.BR pass-update(1)
https://github.com/roddhjav/pass-update from which this script is heavily inspired.

.SH COPYING
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Loading

0 comments on commit d859f54

Please sign in to comment.