diff options
-rw-r--r-- | LICENSE | 14 | ||||
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | README.md | 22 | ||||
-rwxr-xr-x | mkpass | 21 | ||||
-rw-r--r-- | mkpass.1 | 61 |
5 files changed, 133 insertions, 0 deletions
@@ -0,0 +1,14 @@ +BSD Zero Clause License + +Copyright © 2023 Thomas Voss + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1fb7450 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +.POSIX: + +target = mkpass + +PREFIX = /usr/local/bin +DPREFIX = ${DESTDIR}${PREFIX} + +all: ${target} +${target}: + chmod +x $@ + +install: + mkdir -p ${DPREFIX}/bin ${DPREFIX}/man/man1 + cp ${target} ${DPREFIX}/bin + cp ${target}.1 ${DPREFIX}/man/man1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..790935a --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# mkpass + +`mkpass` is a CLI utility to generate passwords from the command\-line. All +random characters are generated by `/dev/urandom`. + +By default passwords are 64 characters long and may contain any printable ASCII +character. If you would like to specify the password length, you can use the +`-l` command\-line option. If you would like to specify the set of characters +to use in the password, you can provide a set of characters or a range in the +same form as `tr(1)`. + +For example to generate a 40 character long password containing only the numbers +0–9 and the uppercase-characters A–F: + + $ mkpass -l 40 0-9A-F + 379A2E98B2BE03A5F4B2F5AC39F4FD8429B2CAFD + +## Installation + +Installation is easy by using the provided Makefile: + + $ sudo make install @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +usage() { + echo "Usage: ${0##*/} [-n] [-l length] [chars]" >&2 + exit 1 +} + +while getopts 'l:n' o; do + case "$o" in + l) len="$OPTARG" ;; + n) nnl=false ;; + *) usage ;; + esac +done + +shift $((OPTIND - 1)) +[ $# -gt 1 ] && usage +</dev/urandom tr -dc -- "${1:-[:graph:]}" | head -c "${len:-64}" +${nnl:-true} && echo diff --git a/mkpass.1 b/mkpass.1 new file mode 100644 index 0000000..84c269f --- /dev/null +++ b/mkpass.1 @@ -0,0 +1,61 @@ +.Dd $Mdocdate: August 22 2023 $ +.Dt MKPASS 1 +.Os +.Sh NAME +.Nm mkpass +.Nd make a password +.Sh SYNOPSIS +.Nm +.Op Fl n +.Op Fl l Ar length +.Op Ar chars +.Sh DESCRIPTION +The +.Nm +utility allows you to easily create randomly\-generated passwords from the +command\-line. +By default, +.Nm +generates a 64\-character long password of printable characters. +If specified, the generated password will only contain characters found in +.Ar chars . +You may use +.Xr tr 1 +range syntax, as shown in the +.Sx EXAMPLES +section. +.Pp +The options are as follows: +.Bl -tag width Ds +.It Fl n +Do not print a trailing newline after the generated password. +.It Fl l Ar length +Generate a password +.Ar length +characters in length. +.El +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +.Pp +Generate a password: +.Pp +.Dl $ mkpass +.Pp +Generate a password with a length of 40: +.Pp +.Dl $ mkpass -l 40 +.Pp +Generate an alphanumeric password: +.Pp +.Dl $ mkpass '[:alnum:]' +.Pp +Generate a password containing only the lowercase letters of the latin alphabet: +.Pp +.Dl $ mkpass a-z +.Sh SEE ALSO +.Xr head 1 , +.Xr totp 1 , +.Xr tr 1 +.Sh AUTHORS +.An Thomas Voss Aq Mt mail@thomasvoss.com |