Skip to content

Instantly share code, notes, and snippets.

@p1nox
Last active April 29, 2022 07:29
Show Gist options
  • Save p1nox/7acda215903af368527777fa8aa90b29 to your computer and use it in GitHub Desktop.
Save p1nox/7acda215903af368527777fa8aa90b29 to your computer and use it in GitHub Desktop.
Ssh tunnels using mole

mole > https://davrodpin.github.io/mole/

Install local:

bash <(curl -fsSL https://raw.githubusercontent.com/davrodpin/mole/master/tools/install.sh)

# or specific version
wget -c https://raw.githubusercontent.com/p1nox/mole/install_spec_version/tools/install.sh -O mole.sh
bash mole.sh v0.5.0 && rm -f mole.sh

# or just v0.5.0 :P
wget -c https://gist.githubusercontent.com/p1nox/7acda215903af368527777fa8aa90b29/raw/16a304b201f4763f5973fb319ad2480b79d5b4fc/mole_050.sh -O mole.sh
bash mole.sh && rm -f mole.sh

Install in docker:

apt-get install -y sudo
wget -c https://raw.githubusercontent.com/davrodpin/mole/master/tools/install.sh -O mole.sh
bash mole.sh && rm -f mole.sh

Simple example:

mole -alias arena_prod -v -insecure \
-local 127.0.0.1:4567 \
-remote 0.0.0.0:4567 \
-server [email protected] \
-key ~/keys_file.pem

mole -start arena_prod

Aws example:

mole -alias redis_customer_prod -v -insecure \
-local :6380 \
-remote dasredis.0001.cache.amazonaws.com:6380 \
-server [email protected] \
-key ~/keys_file.pem

mole -start redis_customer_prod
#!/bin/bash
# MIT License
#
# Copyright (c) 2018 David Pinheiro
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -o pipefail
repository="davrodpin/mole"
install_path="/usr/local/bin"
curl_timeout_seconds=60
echo -ne '\nInstalling mole.\nThis could take a while\n'
# Get the os architecture
os_arch=$(uname -m | tr '[:upper:]' '[:lower:]')
# Check if architecture is supported
if [ "${os_arch}" != "x86_64" ]; then
echo "The ${os_arch} architecture is not supported"
exit 1
fi
# Get the OS type
os_type=$(uname -s | tr '[:upper:]' '[:lower:]')
# Get latest version of mole available
latest_version="v0.5.0"
if [ $? -ne 0 ]; then
echo -ne "\nThere was an error trying to check what is the latest version of mole.\nPlease try again later.\n"
exit 1
fi
filename="mole${latest_version#v}.${os_type}-amd64.tar.gz"
download_link="https://github.com/${repository}/releases/download/${latest_version}/${filename}"
echo $download_link
echo -ne "\nThis script is about to install mole under ${install_path}, but it needs administrator privileges in order to deploy the file. It may require you to type your password below:\n"
curl --silent --location --max-time "${curl_timeout_seconds}" "${download_link}" | sudo tar -xz -C "${install_path}" 2>/dev/null|| {
echo -ne "\nThere was an error trying to install the latest version of mole.\nPlease try again later.\n"
exit 1
}
echo -ne "\nmole ${latest_version} installed succesfully on ${install_path}\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment