Make mkfile accept multiple parameters

This commit is contained in:
Lucas 2022-04-19 03:49:02 +00:00
parent cfd97ff74d
commit d630c83ade
2 changed files with 11 additions and 17 deletions

14
cassh.1
View File

@ -30,13 +30,13 @@
.Bk -words .Bk -words
.Cm mkfile .Cm mkfile
.Ic authorized_keys .Ic authorized_keys
.Op options .Op options ...
.Ek .Ek
.Nm .Nm
.Bk -words .Bk -words
.Cm mkfile .Cm mkfile
.Ic known_hosts .Ic known_hosts
.Op hostnames .Op hostnames ...
.Ek .Ek
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
@ -104,25 +104,25 @@ accepts the tokens %% and %f.
After token expansion, all recognized options are passed down to After token expansion, all recognized options are passed down to
.Xr ssh-keygen 1 .Xr ssh-keygen 1
process. process.
.It Cm mkfile Ic authorized_keys Op Ar options .It Cm mkfile Ic authorized_keys Op Ar options ...
Write an Write an
.Ic authorized_keys .Ic authorized_keys
file on standard output corresponding to the current Certification file on standard output corresponding to the current Certification
Authority. Authority.
.Ar options .Ar options
is copied verbatim to the output, and are concatenated with commas and copied verbatim to the output.
.Cm cert-authority .Cm cert-authority
is always added. is always added to the options list.
See See
.Xr sshd 8 AUTHORIZED_KEYS FILE FORMAT .Xr sshd 8 AUTHORIZED_KEYS FILE FORMAT
for details. for details.
.It Cm mkfile Ic known_hosts Op Ar hostnames .It Cm mkfile Ic known_hosts Op Ar hostnames ...
Write a Write a
.Ic known_hosts .Ic known_hosts
file on standard output corresponding to the current Certification file on standard output corresponding to the current Certification
Authority. Authority.
.Ar hostnames .Ar hostnames
is copied verbatim to the output. are concatenated with commans and copied verbatim to the output.
See See
.Xr sshd 8 SSH_KNOWN_HOSTS FILE FORMAT .Xr sshd 8 SSH_KNOWN_HOSTS FILE FORMAT
for details. for details.

View File

@ -17,8 +17,8 @@ usage()
Usage: Usage:
${0##*/} issue [-hqv] [-I key_id] [-n principals] ${0##*/} issue [-hqv] [-I key_id] [-n principals]
[-V validity_interval] [-V validity_interval]
${0##*/} mkfile authorized_keys [options] ${0##*/} mkfile authorized_keys [options ...]
${0##*/} mkfile known_hosts [hostnames] ${0##*/} mkfile known_hosts [hostnames ...]
EOF EOF
exit 1 exit 1
} }
@ -181,17 +181,11 @@ main_mkfile()
case $file in case $file in
authorized_keys) authorized_keys)
if [ $# -gt 1 ]; then options=$(printf "%s\n" cert-authority "$@" | paste -sd , -)
usage
fi
options=cert-authority${1:+,$1}
printf "%s " "$options" printf "%s " "$options"
;; ;;
known_hosts) known_hosts)
if [ $# -gt 1 ]; then hostnames=$(printf "%s\n" "$@" | paste -sd , -)
usage
fi
hostnames=${1:-}
if [ -n "$hostnames" ]; then if [ -n "$hostnames" ]; then
printf "@cert-authority %s " "$hostnames" printf "@cert-authority %s " "$hostnames"
else else