Skip to content

Instantly share code, notes, and snippets.

@tamsky
Last active August 29, 2015 14:27
Show Gist options
  • Save tamsky/1353addfc67c9266ed87 to your computer and use it in GitHub Desktop.
Save tamsky/1353addfc67c9266ed87 to your computer and use it in GitHub Desktop.
Close all open ControlMaster sockets. Assumes ssh config has "ControlPath ~/.ssh/connections/%r_%h_%p"
(
cd ~/.ssh/connections/
for i in * ; do
PORT=${i##*_}
USER=${i%%_*}
UR=${i%%_$PORT}
REMOTE=${UR##$USER$'_'}
host: ${REMOTE}
ssh ${USER}@${REMOTE} -p ${PORT} -O exit
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment