VOL-630 - update documentation with default creds and doc ssh key support

Change-Id: I96ec086f55d7861068ee59eb63fef7ff79472100
diff --git a/DOCKER_BUILD.md b/DOCKER_BUILD.md
index c277712..acd0777 100644
--- a/DOCKER_BUILD.md
+++ b/DOCKER_BUILD.md
@@ -86,6 +86,10 @@
 ssh -p 5022 voltha@localhost
 ```
 
+_NOTE: The default password used when `ssh`-ing into the VOLTHA CLI is
+`admin`._
+
+
 VOLTHA can be stopped with
 ```bash
 VOLTHA_BUILD=docker make stop
@@ -130,3 +134,55 @@
 ```
 
 _Notice the image names in this output are prefixed with `voltha/`_
+
+# Build VOLTHA CLI to use SSH Keys
+
+The default CLI container build as part of VOLTHA only provides password
+authentication. The following describes how you can build and use a custom
+CLI container that uses custom SSH keys.
+
+## Create the SSH Keys
+The following command can be used to create a valid SSH key:
+```bash
+ssh-keygen -t rsa -N '' -f ./voltha_rsa
+```
+
+This should generate two files: `voltha_rsa` and `voltha_rsa.pub`.
+
+_NOTE: If a different file name is for the key files then the environment
+variable `PUB_KEY_FILE` will have to be specified when the
+`make custom_cli` is executed, as described below. Additionally, when
+`ssh`-ing to VOLTHA, the modified file should be used._
+
+## Build the Custom CLI Container
+There is a make target provided to build the custom CLI container. 
+```bash
+VOLTHA_BUILD=docker make custom_cli
+```
+
+The custom CLI container will, by default, be names `voltha-cli-custom`. If
+you would like to customize the name of the custom docker CLI, this can be 
+done by setting the environment varible `CUSTOM_CLI_LABEL` when executing
+the `make` command, as shown as an example below.
+```bash
+CUSTOM_CLI_LABEL=-my-custom-cli VOLTHA_BUILD=docker make custom_cli
+```
+
+_NOTE: This make target will work with both the Docker and non-Docker builds._
+
+## Running VOLTHA with the Custom CLI Container
+Because the default `start` make target for VOLTHA uses the default CLI
+container, the `CUSTOM_CLI_LABEL` must be specified when executing the
+`start` make taget in order to use the custom CLI container.
+
+```bash
+CUSTOM_CLI_LABEL=-custom VOLTHA_BUILD=docker make start
+```
+
+## SSH-ing to VOLTHA
+Now that the CLI is active with SSH keys, the following command can be
+used to SSH without a password to VOLTHA
+
+```bash
+ssh -i voltha_rsa -p 5022 voltha@localhost
+```
diff --git a/Makefile b/Makefile
index 6e61121..5a67727 100644
--- a/Makefile
+++ b/Makefile
@@ -289,6 +289,13 @@
 	docker build $(DOCKER_BUILD_ARGS) -t ${REGISTRY}${REPOSITORY}voltha-cli:${TAG} -f docker/Dockerfile.cli_d .
 endif
 
+custom_cli: cli
+ifeq ($(CUSTOM_CLI_LABEL),)
+	docker build ${DOCKER_BUILD_ARGS} -t ${REGISTRY}${REPOSITORY}voltha-cli-custom:${TAG} -f docker/Dockerfile.cli_custom .
+else
+	docker build ${DOCKER_BUILD_ARGS} -t ${REGISTRY}${REPOSITORY}voltha-cli${CUSTOM_CLI_LABEL}:${TAG} -f docker/Dockerfile.cli_custom .
+endif
+
 portainer:
 ifneq ($(VOLTHA_BUILD),docker)
 	REGISTRY=${REGISTRY} REPOSITORY=${REPOSITORY} TAG=${TAG} portainer/buildPortainer.sh
diff --git a/compose/voltha-stack.yml.j2 b/compose/voltha-stack.yml.j2
index f8f536f..330131e 100644
--- a/compose/voltha-stack.yml.j2
+++ b/compose/voltha-stack.yml.j2
@@ -412,7 +412,7 @@
   # The CLI container provides an CLI to the VOLTHA capabilitiy 
   # that can be accessed via SSH.
   cli:
-    image: "${REGISTRY}${REPOSITORY}voltha-cli:${TAG:-latest}"
+    image: "${REGISTRY}${REPOSITORY}voltha-cli${CUSTOM_CLI_LABEL}:${TAG:-latest}"
     logging:
       driver: "json-file"
       options:
diff --git a/docker/Dockerfile.cli_custom b/docker/Dockerfile.cli_custom
new file mode 100644
index 0000000..021cc12
--- /dev/null
+++ b/docker/Dockerfile.cli_custom
@@ -0,0 +1,26 @@
+# Copyright 2018 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+ARG TAG=latest
+ARG REGISTRY=
+ARG REPOSITORY=
+
+FROM ${REGISTRY}${REPOSITORY}voltha/voltha-cli:${TAG}
+ARG PUB_KEY_FILE=voltha_rsa.pub
+
+RUN mkdir -p /home/voltha/.ssh
+RUN echo $PUB_KEY_FILE
+COPY ${PUB_KEY_FILE} /home/voltha/.ssh/authorized_keys
+RUN chown -R voltha.voltha /home/voltha/.ssh
+RUN chmod 700 /home/voltha/.ssh
+RUN chmod 600 /home/voltha/.ssh/authorized_keys
diff --git a/scripts/run-voltha.sh b/scripts/run-voltha.sh
index ea88c3b..eff1ce2 100755
--- a/scripts/run-voltha.sh
+++ b/scripts/run-voltha.sh
@@ -29,7 +29,7 @@
 
     TMP_STACK_FILE=$(mktemp -u)
 
-    cat $STACK_TEMPLATE 2>&1 | docker run -e RADIUS_ROOT=$RADIUS_ROOT -e CONSUL_ROOT=$CONSUL_ROOT -e VOLTHA_LOGS=$VOLTHA_LOGS -e SWARM_MANAGER_COUNT=$SWARM_MANAGER_COUNT --rm -i ${REGISTRY}${REPOSITORY}voltha-j2:${TAG} - 2>&1 > $TMP_STACK_FILE
+    cat $STACK_TEMPLATE 2>&1 | docker run -e CUSTOM_CLI_LABEL=$CUSTOM_CLI_LABEL -e RADIUS_ROOT=$RADIUS_ROOT -e CONSUL_ROOT=$CONSUL_ROOT -e VOLTHA_LOGS=$VOLTHA_LOGS -e SWARM_MANAGER_COUNT=$SWARM_MANAGER_COUNT --rm -i ${REGISTRY}${REPOSITORY}voltha-j2:${TAG} - 2>&1 > $TMP_STACK_FILE
     docker stack deploy -c $TMP_STACK_FILE voltha
 
     rm -f $TMP_STACK_FILE
@@ -77,4 +77,4 @@
         echo "Usage: $0 {start|status|stop}" >&2
         exit 1
         ;;
-esac
\ No newline at end of file
+esac