TreeShutter is a macOS-based automation tool for cycling large groups of
switch ports across multiple network switches.
It uses:
- A list of host IPs (
switches.txt) - A credentials file (
creds.txt) - An automation script (
cycle_ports_all.zsh) - The
expectutility to maintain a persistent SSH session per switch
The script performs the following actions on each switch, in a single continuous SSH session:
- Enter configuration mode\
- Shut ports
gi1/0/1–40\ - Wait 5 seconds\
- Bring ports
gi1/0/1–40back up\ - Wait 5 seconds\
- Shut ports
gi2/0/1–40\ - Wait 5 seconds\
- Bring ports
gi2/0/1–40back up\ - Exit configuration mode\
- Log out\
- Move on to the next switch automatically
treeshutter/
│
├── cycle_ports_all.zsh # Main automation script
├── creds.txt # Credentials file (SSH_USER / SSH_PASS)
├── switches.txt # List of switch IPs
└── README.md # This file
TreeShutter runs on macOS using the default zsh shell.
Required to install dependencies:
Used to pass the SSH password non-interactively.
Install:
brew install hudochenkov/sshpass/sshpassUsed to maintain an open SSH session so commands and sleeps can be sequenced correctly.
Install:
brew install expectExample:
SSH_USER=MCAADAdmin
SSH_PASS=YourPasswordHere
Restrict permissions:
chmod 600 creds.txtOne IP per line:
10.101.120.30
10.101.120.31
10.101.120.32
chmod +x cycle_ports_all.zsh
./cycle_ports_all.zsh- Passwords are stored unencrypted in
creds.txt.\ - Use
chmod 600 creds.txtto restrict access.