Skip to content

Commit 29c488f

Browse files
committed
Ensure that the generate test SSH pubkey is copied into the ssh-mount-dummy before the mount test is conducted
1 parent c5c0d0c commit 29c488f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.gocd/key-auth.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if [ ! -r $TEST_SSH_KEY_PATH ]; then
3434
fi
3535

3636
# Read in the public key
37-
MOUNT_SSH_PUB_KEY_CONTENT=`cat $TEST_SSH_KEY_PATH`
37+
MOUNT_SSH_PUB_KEY_CONTENT=`cat $TEST_SSH_KEY_PATH.pub`
3838

3939
# make the plugin
4040
PLUGIN_TAG=$TAG make
@@ -44,13 +44,16 @@ docker plugin enable $SSH_MOUNT_PLUGIN
4444
docker plugin ls
4545
# start sshd
4646
docker run -d -p $MOUNT_PORT:22 --name $SSH_MOUNT_CONTAINER $DOCKER_SSH_MOUNT_IMAGE
47-
# Copy in the public key
48-
docker exec -it $SSH_MOUNT_CONTAINER bash -c "echo $MOUNT_SSH_PUB_KEY_CONTENT >> $MOUNT_PATH/.ssh/authorized_keys"
49-
5047
# It takes a while for the container to start and be ready to accept connection
5148
# TODO, check when container is ready instead of sleeping
5249
sleep 20
5350

51+
# Copy in the public key
52+
# Write a newline followed by the public key
53+
# https://unix.stackexchange.com/questions/191694/how-to-put-a-newline-special-character-into-a-file-using-the-echo-command-and-re
54+
docker exec -it $SSH_MOUNT_CONTAINER bash -c $"echo \n >> $MOUNT_PATH/.ssh/authorized_keys"
55+
docker exec -it $SSH_MOUNT_CONTAINER bash -c "echo $MOUNT_SSH_PUB_KEY_CONTENT >> $MOUNT_PATH/.ssh/authorized_keys"
56+
5457
# test1: ssh key
5558
docker plugin disable $SSH_MOUNT_PLUGIN
5659
docker plugin set $SSH_MOUNT_PLUGIN sshkey.source=$TEST_SSH_KEY_DIRECTORY

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ docker plugin install ucphhpc/sshfs state.source=<any_folder> sshkey.source=/hom
6161

6262
2 - Create a volume
6363

64-
> Make sure the ***source path on the ssh server was exists***.
64+
> Make sure the ***source path on the ssh server exists***.
6565
>
66-
> Or you'll be failed while use/mount the volume.
66+
> Or you will fail when you use/mount the volume.
6767
6868
```
6969
$ docker volume create -d ucphhpc/sshfs -o sshcmd=<user@host:path> [-o IdentityFile=/root/.ssh/<key>] [-o port=<port>] [-o <any_sshfs_-o_option> ] sshvolume

0 commit comments

Comments
 (0)