NAME

Net::SSH::Tunnel - This is a simple wrapper around ssh to establish a tunnel. Supports both local and remote port forwarding.

VERSION

Version 0.01

SYNOPSIS

Perl module to setup / destroy a ssh tunnel.

# create a very short driver script.
$ vi driver.pl
#!/usr/bin/perl

use strict;
use warnings;
use Net::SSH::Tunnel;

Net::SSH::Tunnel->run();

# run the driver script with options.
$ ./driver.pl --host dest.example.com --hostname hostname.example.com

# the above is equivalent to creating a local port forwarding like this:
# ssh -f -N -L 10000:dest.example.com:22 <effective username>@hostname.example.com

# after the driver script is done, you can then do:
ssh -p 10000 user@localhost

# Notes on testing:
# This module wraps around ssh and as such, requires authentication.
# I have included test_deeply.pl that asks for hostnames, runs ssh and establishes a tunnel.
# If you'd like to test manually, please use the script.

SUBROUTINES/METHODS

new

Description: The constructor.  Creates an object, invokes init() for argument parsing
Arguments: none
Returns: object

init

Description: Arg parser.  Sets default values, uses Getopt::Long then do the necessary parsing.
Arguments: none
Returns: none, but updates the object with parsed args.  Croaks on error.

run

Description: Driver method to do the new()->init() dance, then calls appropriate methods based on the args
Arguments: none
Returns: none, but may croak on error

setup_tunnel

Description: Establishes a ssh tunnel based on the object info.
Arguments: none
Returns: none, but may croak on error

check_tunnel

Description: Runs ps and finds an existing tunnel, according to the parameters supplied
Arguments: none
Returns: pid of tunnel

destroy_tunnel

Description: Calls check_tunnel() for existing tunnel, and if it exists, kills it.
Arguments: none
Returns: none, croaks if it fails to kill.  if there wasn't a tunnel, it doesn't do anything

usage

Description: The sub to provide help.
Arguments: none
Returns: none, and exits

AUTHOR

Satoshi Yagi, <satoshi.yagi at yahoo.com>

BUGS

Please report any bugs or feature requests to bug-net-ssh-tunnel at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-SSH-Tunnel. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Net::SSH::Tunnel

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2012 Satoshi Yagi.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.