Dotfiles/site-modules/core/files/bin/knock
Ade Attwood 80239af169 refactor(core): start to make dotfiles public
This is the first commit that brings the privet dotfiles to a public
reop previously this was all one puppet module. Now this has been split
out so I can put all of the private files in a private puppet module
2020-09-20 06:22:17 +01:00

33 lines
694 B
Bash
Executable file

#!/usr/bin/env bash
#
# Sends a http request to a URL and a port. This is used to knock on port to
# open other ports. See: https://wiki.archlinux.org/index.php/Port_knocking
#
# Using this in your `.ssh/config` as a proxy command can be a nice way to
# automatically knock on ports before connecting with ssh.
#
# Example:
#
# ```
# ProxyCommand bash -c '/home/ade/.dotfiles/bin/knock %h {port_number}; exec /bin/nc %h %p'
# ```
#
# Author: Ade Attwood <code@adeattwood.co.uk>
# Created: 2019-07-11
#
#
# Set off the http request
#
curl --max-time 5 http://$1:$2 > /dev/null 2>&1 &
#
# Wait for a fuw seconds
#
sleep 2.5
#
# Return a success code to carry on the ssh connection
#
exit 0;