<commit_before># Tnnl

Tnnl is a command-line utility for wrangling SSH tunnels.

This will eventually be released as a gem. For now, it's just a pile of lovely,
lovely code.

Unlike pretty much every other SSH tunnel utility I've come across, Tnnl will 
not store your preferences in some random YAML file. Instead it will try to 
make good use of your native SSH config (at `~/.ssh/config` for most folks).

The command-line interface will look something like this:

    $ tnnl 1234:user@host:5678
    #=> Opens a tunnel from local port 1234 to port 5678 on host.
    #=> This will fork a new process and return your command prompt.
    
    $ tnnl user@host:3000
    #=> Tries to use 3000 for the local port, and increments until it finds an
    #=> open local port.
    
    $ tnnl foo:3000
    #=> Looks up username and hostname in your SSH config under "foo".
    
    $ tnnl list
    1. local:3307 ===> foo:3306
    2. local:3000 ===> 172.16.58.3:3000
    3. local:666  ===> chunkybacon.org:666

    $ tnnl close 1 3
    #=> Closes tunnels #1 and #3 from the list.
    
    $ tnnl close all
    #=> Closes all tunnels.<commit_msg>Update README.md for initial release.<commit_after># Tnnl

Tnnl is a command-line utility for wrangling SSH tunnels.

Unlike most SSH tunnel utilities I've come across, Tnnl will not clutter your filesystem with a preferences YAML file. Instead it will try to make use of your native SSH config (at `~/.ssh/config` for most folks).

__This project is still in an early/alpha state. You have been warned. :)__

## Usage

### Open an SSH tunnel

Open an SSH tunnel between local port 1234 and port 5678 on the remote host `mysql.spatula.grommet`. If local port 1234 is unavailable, Tnnl will increment by 1 until it finds an open port.

    $ tnnl 1234:<EMAIL>:3306

You can omit the local port number, and Tnnl will try to use the same port for the local and remote hosts.
    
    $ tnnl <EMAIL>:3306
    
If you have defined a host alias in your SSH config, you can save yourself some keystrokes by referencing that alias.

    $ tnnl db:3306

### Find and close open tunnels
    
Use `tnnl list` to list all open SSH tunnels that were created by Tnnl.

    $ tnnl list
    1. localhost:3307  ==>  mysql.spatula.grommet:3306
    2. localhost:3000  ==>  172.16.17.32:3000
    3. localhost:666   ==>  chunkybacon.gov:666

You can use the index numbers referenced in `tnnl list` to close 1 or more tunnels.

    $ tnnl close 2
    $ tnnl close 1 3

Or close all tunnels created by Tnnl.

    $ tnnl close all

## Known Issues

- The list feature relies on renaming processes via $0, which does not work properly on Ruby 1.9.3-p0 on OS X. This appears to be an issue with this particular build of Ruby on this platform (https://groups.google.com/forum/#!topic/urug/zfmEGqjX47M). 1.9.3-p0 users on OS X are encouraged to upgrade to a newer build.
- Tnnl uses Net::SSH under the hood, and Net::SSH currently supports only a subset of OpenSSH configuration options. The `StrictHostKeyChecking` preference is not supported, so Tnnl errs on the safe side and prompts you to update ~/.ssh/known_hosts when a modified host key is detected. Feel free to open an issue and/or submit a pull request if this is ruining your day.
{'fraction_non_alphanumeric': 0.07013226699477083, 'fraction_numerical': 0.04398646570286066, 'mean_word_length': 3.2233766233766232, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5022431', 'n_tokens_mistral': 1119, 'n_tokens_neox': 979, 'n_words': 486}