Skip to content

Instantly share code, notes, and snippets.

@jathanism
Last active September 15, 2015 20:34
Show Gist options
  • Select an option

  • Save jathanism/b47112f22b8d940e5437 to your computer and use it in GitHub Desktop.

Select an option

Save jathanism/b47112f22b8d940e5437 to your computer and use it in GitHub Desktop.
Illustrates how Trigger can control and capture anything over it's master SSH connection, even connections to other systems.
from trigger.netdevices import NetDevices
import StringIO
nd = NetDevices()
dev = nd.find('ubuntu.local')
logger = StringIO.StringIO()
dev.connect(output_logger=logger)
# Interactive stdio over the pty session.
"""
Connecting to ubuntu.local. Use ^X to exit.
Fetching credentials from /Users/jathan/.tacacsrc
Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.13.0-52-generic x86_64)
* Documentation: https://help.ubuntu.com/
New release '14.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Your Hardware Enablement Stack (HWE) is supported until April 2017.
Last login: Tue Sep 15 13:28:06 2015 from jathan-mbp.local
jathan at ubuntu in ~
$ ssh oobliss.com
[email protected]'s password:
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-32-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Tue Sep 15 16:11:42 EDT 2015
System load: 0.0 Processes: 85
Usage of /: 19.0% of 29.40GB Users logged in: 0
Memory usage: 19% IP address for eth0: 107.170.232.13
Swap usage: 0%
Graph this data and manage this system at:
https://landscape.canonical.com/
79 packages can be updated.
28 updates are security updates.
*** System restart required ***
Last login: Tue Sep 15 16:11:45 2015 from cpe-45-48-180-100.socal.res.rr.com
jathan at devbox in ~
$ exit
Connection to oobliss.com closed.
jathan at ubuntu in ~
$ exit
"""
# Returns 0
print logger.getvalue()
# Captured logger output:
"""
Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.13.0-52-generic x86_64)
* Documentation: https://help.ubuntu.com/
New release '14.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Your Hardware Enablement Stack (HWE) is supported until April 2017.
Last login: Tue Sep 15 13:28:06 2015 from jathan-mbp.local
jathan at ubuntu in ~
$ ssh oobliss.com
[email protected]'s password:
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-32-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Tue Sep 15 16:11:42 EDT 2015
System load: 0.0 Processes: 85
Usage of /: 19.0% of 29.40GB Users logged in: 0
Memory usage: 19% IP address for eth0: 107.170.232.13
Swap usage: 0%
Graph this data and manage this system at:
https://landscape.canonical.com/
79 packages can be updated.
28 updates are security updates.
*** System restart required ***
Last login: Tue Sep 15 16:11:45 2015 from cpe-45-48-180-100.socal.res.rr.com
jathan at devbox in ~
$ exit
Connection to oobliss.com closed.
jathan at ubuntu in ~
$ exit
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment