-
-
Save alex-hofsteede/dc0113fddde3b80f0cce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python | |
import subprocess | |
import sys | |
""" | |
Used in a tmux session, connects a synchronized interactive ssh session to all | |
hostnames read from stdin (1 per line). Preserves all ssh arguments. | |
Example usage: | |
tmux | |
./sshmux.py -i my-key.pem -o "User root" < hosts.txt | |
""" | |
for i, host in enumerate(sys.stdin): | |
args = " ".join(['"%s"' % arg for arg in sys.argv[1:]] + [host.strip()]) | |
if i == 0: | |
subprocess.call(["tmux", "new-window", 'ssh %s' % args]) | |
else: | |
pass | |
subprocess.call(["tmux", "split-window", "-h", 'ssh %s' % args]) | |
subprocess.call(["tmux", "select-layout", "tiled"]) | |
subprocess.call(["tmux", "select-pane", "-t", "0"]) | |
subprocess.call(["tmux", "set-window-option", "synchronize-panes", "on"]) |
This file contains hidden or 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
#!/usr/bin/python | |
import subprocess | |
import sys | |
""" | |
Used in a tmux session, connects a synchronized interactive ssh session to all | |
hostnames read from stdin (1 per line). Preserves all ssh arguments. | |
Example usage: | |
tmux | |
./sshmux.py -i my-key.pem -o "User root" < hosts.txt | |
""" | |
for i, host in enumerate(sys.stdin): | |
args = " ".join(['"%s"' % arg for arg in sys.argv[1:]] + [host.strip()]) | |
if i == 0: | |
subprocess.call(["tmux", "new-window", 'ssh %s' % args]) | |
else: | |
pass | |
subprocess.call(["tmux", "split-window", "-h", 'ssh %s' % args]) | |
subprocess.call(["tmux", "select-layout", "tiled"]) | |
subprocess.call(["tmux", "select-pane", "-t", "0"]) | |
subprocess.call(["tmux", "set-window-option", "synchronize-panes", "on"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment