Skip to content

Instantly share code, notes, and snippets.

@lusis
Last active April 8, 2016 05:25
Show Gist options
  • Save lusis/869fe3bf2ebcd4a5be7411580bc430ce to your computer and use it in GitHub Desktop.
Save lusis/869fe3bf2ebcd4a5be7411580bc430ce to your computer and use it in GitHub Desktop.
Rundeck with Jump Hosts
#!/bin/bash
KEYPATH=$1
shift
JUMPUSER=$1
shift
JUMPHOST=$1
shift
JUMPKEY=$1
shift
REALUSER=$1
shift
REALHOST=$1
shift
DESTFILE=$1
shift
JOBFILE=$1
COMMON_SSHOPTS="-q -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null"
exec scp -i $KEYPATH \
-o "ProxyCommand ssh ${COMMON_SSHOPTS} -W %h:%p -i ${JUMPKEY} $JUMPUSER@$JUMPHOST" \
${COMMON_SSHOPTS} \
$JOBFILE ${REALUSER}@${REALHOST}:${DESTFILE}
#!/bin/bash
# This is the command we want to run in the end
#ssh -i ${node.ssh-keypath} -o "ProxyCommand ssh -W %h\:%p -i ${node.jumpNode_key} ${node.jumpNode_user}@${node.jumpNode}" ${node.user}@${node.hostname}'
# arg1: keypath
# arg2: jumpuser
# arg3: jumphost
# arg4: jumpnodekey
# arg5: realuser
# arg6: realhost
# arg7: --
KEYPATH=$1
shift
JUMPUSER=$1
shift
JUMPHOST=$1
shift
JUMPKEY=$1
shift
REALUSER=$1
shift
REALHOST=$1
shift
DASH=$1
shift
COMMAND=$@
COMMON_SSHOPTS="-q -a -T -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null"
#COMMON_SSHOPTS="-q -a -T -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o ControlPersist=10 -o ControlMaster=auto -o ControlPath=/tmp/%r@%h:%p"
exec ssh -i \
$KEYPATH \
-o "ProxyCommand ssh ${COMMON_SSHOPTS} -W %h:%p -i ${JUMPKEY} $JUMPUSER@$JUMPHOST" \
${COMMON_SSHOPTS} \
${REALUSER}@${REALHOST} \
"${COMMAND}"
foo.spathops.local:
description: "foo server"
hostname: foo.spathops.local
nodename: foo.spathops.local
osArch: x86_64
node-executor: script-exec
file-copier: script-copy
osFamily: unix
osName: Linux
tags: spathops,foo
username: admin
ssh-keypath: /keypath/rundeck-key
jumpNode: X.X.X.X
jumpNode_user: <username>
jumpNode_key: /keypath/rundeck-key
plugin.script-copy.default.command=/data/rundeck_scripts/gateway-copier-v2.sh ${node.ssh-keypath} ${node.jumpNode_user} ${node.jumpNode} ${node.jumpNode_key} ${node.username} ${node.hostname} ${file-copy.destination} ${file-copy.file}
plugin.script-copy.default.remote-filepath=${node.destdir}/${file-copy.filename}
plugin.script-exec.default.command=/data/rundeck_scripts/gateway-runner-v2.sh ${node.ssh-keypath} ${node.jumpNode_user} ${node.jumpNode} ${node.jumpNode_key} ${node.username} ${node.hostname} -- ${exec.command}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment