Created
April 30, 2020 01:46
-
-
Save madars/e6b957ea508be1dcd9044fd2c70969ac 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