Last active
February 24, 2017 01:40
-
-
Save iamahuman/19d95e0df1cf829d65c035779e0edf99 to your computer and use it in GitHub Desktop.
ifconfig wrapper with SSH connection protection
This file contains 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 | |
if [ -n "$SSH_CONNECTION" ] && [ "$2" = "down" ]; then | |
IFS=' ' read -ra conn_info <<< "$SSH_CONNECTION" | |
if ip address show "$1" | grep -q "${conn_info[2]}"; then | |
echo "Warning: Current SSH connection is bound on ${conn_info[2]} ($1)" >&2 | |
exit 1 | |
fi | |
fi | |
exec /sbin/ifconfig "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment