SSH Tunnel

Alfred Botman

Compatibility:

Description

This module will make the botman to start an SSH tunnel.
This may allow you to get an ssh access to a NATed bot.

Configuration

You need a configuration file (/usr/local/etc/gotham/modules.conf.d/ssh_tunnel.conf):

{
   "vars" : [
      "raid_status",
      "disk_full"
   ]
}
The vars array contains the list of custom variables that will be shown when showing bots affected by the .ssh commands.

{
   "command" : "/usr/bin/ssh",
   "host" : "ssh.master.com",
   "login" : "support",
   "key" : "/usr/local/share/gotham/modules.d/ssh_tunnel/id_rsa_support",
   "port" : 22
}
This file contains informations needed to start a reverse ssh tunnel on the host.


Query botmans through Alfred

It is possible to make Alfred able to query botmans for you by combining the power of the spam and rewrite modules.
You can add the following JSON object as a new rule of the rewrite module’s configuration file:

{
   "name" : ".ssh on",
   "filter" : ".ssh * on",
   "rule" : "sed -r 's/^.ssh *([^ ]*) on/.spam \\1 .ssh on/'",
   "description" : ".ssh <pattern> on"
}, {
   "name" : ".ssh off",
   "filter" : ".ssh * off",
   "rule" : "sed -r 's/^.ssh *([^ ]*) off/.spam \\1 .ssh off/'",
   "description" : ".ssh <pattern> off"
}


Example use:

Alfred

This command will search through Alfred’s cache to find every SSH tunnel opened through him (and the spam module).
It won’t send a message to every botman to get the information, so tunnels opened directly by talking to a botman might not appear.
(16:27:43) guillaume.friloux@botman.master.com: .ssh
(16:27:43) Alfred Pennyworth:
Contacts with an opened tunnel :
   online botman.1@botman.master.com : Port 42461
   online botman.2@botman.master.com : Port 57887
(16:41:18) guillaume.friloux@botman.master.com: .ssh on
(16:41:18) botman: Tunnel opened on port 58462, pid 37669
(16:43:37) guillaume.friloux@botman.master.com: .ssh off
(16:43:37) botman: Tunnel has died