-
-
Save mikalv/a3f8f415b477e5590521b86f1239dc31 to your computer and use it in GitHub Desktop.
A read-only tmux session for demos and remote debugging
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/sh | |
# To be used with something like this in sshd_config: | |
# | |
# Match User public-tmux | |
# X11Forwarding no | |
# AllowTcpForwarding no | |
# PasswordAuthentication yes | |
# ForceCommand /usr/bin/tmux -S /tmp/public-tmux-socket attach -r -t public | |
# | |
SOCKET=/tmp/public-tmux-socket | |
if tmux -S $SOCKET list-sessions 2>/dev/null | grep -q ""; then | |
echo "The socket at $SOCKET already has sessions, attaching..." | |
exec tmux -S $SOCKET attach -t public | |
else | |
echo "Creating a new tmux session with socket at $SOCKET and changing it to be world-writeable..." | |
exec tmux -S $SOCKET new-session -s public "chmod o=w $SOCKET; $SHELL" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment