From a765789c4d5ae784fc23b64247af7ebc4fb5384c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 22:01:52 -0500 Subject: [PATCH] Allow customizing ssh port for the default client Closes #1942 --- contrib/dokku_client.sh | 10 ++++++---- docs/community/clients.md | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/contrib/dokku_client.sh b/contrib/dokku_client.sh index e86a6962d..823f5398d 100755 --- a/contrib/dokku_client.sh +++ b/contrib/dokku_client.sh @@ -41,6 +41,8 @@ if [[ -z $DOKKU_HOST ]]; then fi fi +export DOKKU_PORT=${DOKKU_PORT:=22} + if [[ ! -z $DOKKU_HOST ]]; then _dokku() { appname="" @@ -72,10 +74,10 @@ if [[ ! -z $DOKKU_HOST ]]; then if [[ -z "$2" ]]; then appname=$(random_name) counter=0 - while ssh "dokku@$DOKKU_HOST" apps 2>/dev/null| grep -q "$appname"; do + while ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps 2>/dev/null| grep -q "$appname"; do if [[ $counter -ge 100 ]]; then echo "Error: could not reasonably generate a new app name. try cleaning up some apps..." - ssh "dokku@$DOKKU_HOST" apps + ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps exit 1 else appname=$(random_name) @@ -98,7 +100,7 @@ if [[ ! -z $DOKKU_HOST ]]; then if [[ -z "$donotshift" ]]; then # shellcheck disable=SC2029 - ssh -o LogLevel=QUIET -t "dokku@$DOKKU_HOST" "$@" + ssh -o LogLevel=QUIET -p "$DOKKU_PORT" -t "dokku@$DOKKU_HOST" "$@" exit $? fi @@ -125,7 +127,7 @@ if [[ ! -z $DOKKU_HOST ]]; then fi fi # shellcheck disable=SC2086,SC2029 - ssh -o LogLevel=QUIET -t "dokku@$DOKKU_HOST" $long_args "$verb" "$appname" "${args[@]}" + ssh -o LogLevel=QUIET -p "$DOKKU_PORT" -t "dokku@$DOKKU_HOST" $long_args "$verb" "$appname" "${args[@]}" } if [[ "$0" == "dokku" ]] || [[ "$0" == *dokku_client.sh ]] || [[ "$0" == $(which dokku) ]]; then diff --git a/docs/community/clients.md b/docs/community/clients.md index 9fee9bfb1..756806939 100644 --- a/docs/community/clients.md +++ b/docs/community/clients.md @@ -33,6 +33,8 @@ alias dokku 'bash $HOME/.dokku/contrib/dokku_client.sh' Configure the `DOKKU_HOST` environment variable or run `dokku` from a repository with a git remote named dokku pointed at your dokku host in order to use the script as normal. +You can also configure a `DOKKU_PORT` environment variable if you are running ssh on a non-standard port. This defaults to `22`. + ## (nodejs) dokku-toolbelt Dokku-toolbelt is a node-based cli wrapper that proxies requests to the dokku command running on remote hosts. You can install it via the following shell command (assuming you have nodejs and npm installed):