The basic idea of an SSH tunnel is that the SSH client connects to an SSH server and it will map a local port to a remote port. That means that anything that connects to the local port will get forwarded to a remote system and port. For example, you have an SSH server at 192.168.1.1 and a telnet server at 192.168.2.1. You can use an SSH client to connect to the SSH server and configure a tunnel that will map local port 23 (i.e. 127.0.0.1:23) to port 23 on the telnet server (i.e. 192.168.2.1:23). Then you can use a telnet client and tell it to connect to local port 23 (127.0.0.1:23) and the SSH client will route that to 192.168.2.1:23 via the SSH server.

You can go to this Wikipedia page (click here) to get some more information. Unfortunately, the example near the end of the page is not the type of port that you would need to setup. Click here for an example of how to do this from a Linux environment. From a Windows system, you can use putty as an SSH client. See here for instructions on how to setup a tunnel using the GUI interface for putty or you can look here for information on how to setup a tunnel via command line parameters.

In your case, you can manually use an SSH client to establish a connection to your SSH server and to create the needed tunnel. Going that route means that you probably don't need to change your code - if I understand your situation correctly. Alternatively, you can use Net::SSH2 (or other appropriate SSH related modules) to connect to the SSH server and create the tunnel within your code.


In reply to Re^5: Changing a script from Net::Telnet to Net::SSH2 by dasgar
in thread Changing a script from Net::Telnet to Net::SSH2 by jtzako

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.