File tree Expand file tree Collapse file tree 7 files changed +27
-11
lines changed
Expand file tree Collapse file tree 7 files changed +27
-11
lines changed Original file line number Diff line number Diff line change 11version : 2
22jobs :
33 build :
4- machine :
5- docker_layer_caching : true
4+ machine : {}
65 steps :
76 - checkout
87 - run :
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ MAINTAINER_NAME = Jose Diaz-Gonzalez
66REPOSITORY = sshcommand
77HARDWARE = $(shell uname -m)
88SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]')
9- BASE_VERSION ?= 0.8 .0
9+ BASE_VERSION ?= 0.9 .0
1010IMAGE_NAME ?= $(MAINTAINER ) /$(REPOSITORY )
1111PACKAGECLOUD_REPOSITORY ?= dokku/dokku-betafish
1212
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ ssh ls@server <your-args>
2020sshcommand create < USER> < COMMAND> # Creates a user forced to run command when SSH connects
2121sshcommand acl-add < USER> < NAME> < KEY_FILE> # Adds named SSH key to user from STDIN or argument
2222sshcommand 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
2424sshcommand help < COMMAND> # Shows help information
2525sshcommand version # Shows version
2626```
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change @@ -174,17 +174,22 @@ sshcommand-acl-remove() {
174174}
175175
176176sshcommand-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
190195sshcommand-help () {
Original file line number Diff line number Diff 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)" {
You can’t perform that action at this time.
0 commit comments