Last active
October 20, 2017 04:07
-
-
Save ericwastaken/f9fffbd780962504da64c46b2ee42764 to your computer and use it in GitHub Desktop.
Stops a previously started SSH tunnel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ********************************************************************* | |
# script: ssh-forward-stop.sh | |
# summary: Stops an SSH Port Forward process, previously started by | |
# the companion script `ssh-forward-start.sh`. | |
# | |
# Tested on macOS Sierra. | |
# | |
# dependencies: | |
# - The forward must have been started by the companion script. | |
# - The PID file must be present in the current folder. | |
# | |
# ********************************************************************* | |
pid_filename="ssh-forward.pid" | |
echo "" | |
echo "ssh-forward-stop.sh" | |
echo "Stops an SSH Port Forward Session, previously started." | |
echo "Assumes you started the Forward Session with the companion script." | |
echo "" | |
if [[ -f ${pid_filename} ]]; then | |
ssh_pid=$(cat ${pid_filename}) | |
kill -9 ${ssh_pid} | |
rm ${pid_filename} | |
echo "done: ssh fw stopped!" | |
else | |
echo "error: ssh fw process not found! Start one with ssh-forward-start.sh!" | |
fi | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment