Skip to content

Commit 99257e1

Browse files
authored
Merge pull request #49 from dokku/master
Release 0.9.0
2 parents cfd30b1 + 38b0afa commit 99257e1

File tree

7 files changed

+27
-11
lines changed

7 files changed

+27
-11
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
version: 2
22
jobs:
33
build:
4-
machine:
5-
docker_layer_caching: true
4+
machine: {}
65
steps:
76
- checkout
87
- run:

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ All notable changes to this project will be documented in this file.
1010

1111
### Changed
1212

13+
## [0.9.0] - 2019-09-20
14+
15+
### Added
16+
- @josegonzalez Add ability to list a single name's keys
17+
1318
## [0.8.0] - 2019-08-10
1419
### Fixed
1520
- @fruitl00p delete_user is now portable
@@ -113,7 +118,8 @@ All notable changes to this project will be documented in this file.
113118
- @michaelshobbs update build image in README
114119
- @jvanbaarsen Only add SSH key if it doesn't already exists
115120

116-
[unreleased]: https://github.com/dokku/sshcommand/compare/v0.8.0...HEAD
121+
[unreleased]: https://github.com/dokku/sshcommand/compare/v0.9.0...HEAD
122+
[0.9.0]: https://github.com/dokku/sshcommand/compare/v0.8.0...v0.9.0
117123
[0.8.0]: https://github.com/dokku/sshcommand/compare/v0.7.0...v0.8.0
118124
[0.7.0]: https://github.com/dokku/sshcommand/compare/v0.6.0...v0.7.0
119125
[0.6.0]: https://github.com/dokku/sshcommand/compare/v0.5.0...v0.6.0

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MAINTAINER_NAME = Jose Diaz-Gonzalez
66
REPOSITORY = sshcommand
77
HARDWARE = $(shell uname -m)
88
SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]')
9-
BASE_VERSION ?= 0.8.0
9+
BASE_VERSION ?= 0.9.0
1010
IMAGE_NAME ?= $(MAINTAINER)/$(REPOSITORY)
1111
PACKAGECLOUD_REPOSITORY ?= dokku/dokku-betafish
1212

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ssh ls@server <your-args>
2020
sshcommand create <USER> <COMMAND> # Creates a user forced to run command when SSH connects
2121
sshcommand acl-add <USER> <NAME> <KEY_FILE> # Adds named SSH key to user from STDIN or argument
2222
sshcommand acl-remove <USER> <NAME> # Removes SSH key by name
23-
sshcommand list <USER> # Lists SSH user keys by name
23+
sshcommand list <USER> [<NAME>] # Lists SSH keys by user and an optional name
2424
sshcommand help <COMMAND> # Shows help information
2525
sshcommand version # Shows version
2626
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sshcommand",
3-
"version": "0.0.1",
3+
"version": "0.9.0",
44
"description": "Turn SSH into a thin client specifically for your app",
55
"global": "true",
66
"install": "cp sshcommand /usr/local/bin && chmod +x /usr/local/bin/sshcommand",

sshcommand

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,22 @@ sshcommand-acl-remove() {
174174
}
175175

176176
sshcommand-list() {
177-
declare desc="Lists SSH user keys by name"
178-
declare userhome USER="$1"
177+
declare desc="Lists SSH keys by user and an optional name"
178+
declare userhome USER="$1" NAME="$2"
179179
[[ -z "$USER" ]] && log-fail "Usage: sshcommand list" "$(fn-args "sshcommand-list")"
180180

181181
getent passwd "$USER" > /dev/null || log-fail "\"$USER\" is not a user on this system"
182182
userhome=$(sh -c "echo ~$USER")
183183
[[ -e "$userhome/.ssh/authorized_keys" ]] || log-fail "authorized_keys not found for $USER"
184184
[[ -s "$userhome/.ssh/authorized_keys" ]] || log-fail "authorized_keys is empty for $USER"
185-
sed --silent --regexp-extended \
186-
's/^command="FINGERPRINT=(\S+) NAME=(\\"|)(.*)\2 `.*",(\S+).*/\1 NAME="\3" SSHCOMMAND_ALLOWED_KEYS="\4"/p' \
187-
"$userhome/.ssh/authorized_keys"
185+
OUTPUT="$(sed --silent --regexp-extended \
186+
's/^command="FINGERPRINT=(\S+) NAME=(\\"|)(.*)\2 `.*",(\S+).*/\1 NAME="\3" SSHCOMMAND_ALLOWED_KEYS="\4"/p' \
187+
"$userhome/.ssh/authorized_keys")"
188+
if [[ -n "$NAME" ]]; then
189+
echo "$OUTPUT" | grep "NAME=\"$NAME\""
190+
else
191+
echo "$OUTPUT"
192+
fi
188193
}
189194

190195
sshcommand-help() {

tests/unit/core.bats

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ check_custom_allowed_keys() {
175175
echo "output: "$output
176176
echo "status: "$status
177177
assert_failure
178+
179+
cp tests/unit/fixtures/authorized_keys/input_variants /home/${TEST_USER}/.ssh/authorized_keys
180+
run sshcommand list ${TEST_USER} md5
181+
assert_equal \
182+
"$(cat tests/unit/fixtures/authorized_keys/sshcommand_list_expected_output | head -n1)" \
183+
"$(sshcommand list ${TEST_USER} md5)"
178184
}
179185

180186
@test "(core) sshcommand list (authorized_keys format variants)" {

0 commit comments

Comments
 (0)