Appendix A: Getting started with SSH visualization

With Python script graph_ssh_sessions.py it is possible to create visualizations of complex SSH network connectivity’s as shown in Picture 1 and 4. The script uses the csv output of the following Tanium question as input:

Get Computer Name and SSH Audit - Authorized Keys[0] and SSH Audit - Private Keys from all machines

An output file is created (with instructions) to graph the possible SSH publickey authentications.

The output is either a DOT or GEXF (Graph Exchange XML Format) file from which a .svg or .png file can be generated using a Graphviz based tool like Cytoscape or Gephi. Cytoscape seems to be better in quickly analyzing large networks, but it requires installing a GEXF plugin. Gephi can read both DOT and GEXF files. DOT files are easier to manipulate afterwards using an editor.

The execution requirements of graph_ssh_sessions.py are a desktop or server with python3 and the “network” module (pip3 install network) installed.

Refer to the Graph_ssh_session sample script section below for a sample script.

Usage and options

usage: graph_ssh_sessions.py [-h] -i INFILE [-f {dot,gexf}] [-o OUTFILE] [-v]

Options:

 

-h

show this help message and exit

-i INFILE

input csv file

- f {dot,gexf}

output file format [gexf]

-o OUTFILE

output file [ssh_authorized_keys.(dot|gexf)]

-v

print detailed publickey information

Getting started with Cytoscape or Gephi

Both Cytoscape and Gephi require manual efforts to render the network diagrams nicely with arrows showing which authorized key grants access to user@computer_name.

  • Cytoscape

    • Read your .gexf file.

    • Select the Detach View button.

    • Select the Refresh button.

    • From the Style options on the left bar, select style Curved.

    • Use drag and drop to alter node and edge positions.

  • Gephi:

    • Read your .dot or .gexf file (ignore any warnings)

    • Select the Preview button in the top bar.

    • Select Edges Custom Color and click the Refresh button.

    • Select Overview to alter node and edge positions.

Graph_ssh_session sample script

Click here to access graph_ssh_session sample (requires a Tanium Resource Center login).