Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Changing a script from Net::Telnet to Net::SSH2

by perlfan (Priest)
on Mar 03, 2016 at 21:08 UTC ( #1156768=note: print w/replies, xml ) Need Help??

in reply to Changing a script from Net::Telnet to Net::SSH2

telnet and ssh operate and different levels. telnet is a client for interacting with various daemons and it typically very low level; for example, it is useful for talking directly with things like an http or mail server. You are basically participating in the protocol exchange directly.

ssh on the other hand, is a client to sshd; this provides a secure access to the userland shell of the system you're logging into (among other things); for example, you can telnet over an ssh tunnel (which it sounds like what you might need to do in order to retain your functionality).

See A little demo for Net::SSH2 for a Net::SSH2 demonstration. For some perspective on the differences between telnet and ssh, check out

  • Comment on Re: Changing a script from Net::Telnet to Net::SSH2

Replies are listed 'Best First'.
Re^2: Changing a script from Net::Telnet to Net::SSH2
by jtzako (Sexton) on Mar 03, 2016 at 21:14 UTC
    Essentially what I have to do is SSH2 to the jumphost. Then from there I can use telnet to get to individual devices. Previously it was possible to get to jumphost via telnet and that is what this script was using. I'd like to figure out a way to do the SSH2 to jumphost bit then do the telnet to devices etc. The difference seems to be the way it handles 'printing' the commands I need to run. Most examples I found do not use the $ssh2-> type of setup which is what ours was using. For example "$t->print" says it is not a valid SSH2 macro.

      I completely misunderstood what you were trying to do. Based on your problem description, I thought you were connecting to something via telnet and now wanted to connect via SSH. But what you're now describing is needing to SSH into one system and then from there telnet into a second system. That's a completely different scenario.

      Now that I understand what it is you're trying to do, I agree with perlfan that creating an SSH tunnel is probably what you might want to consider. After you create the tunnel, your existing code using Net::Telnet just needs to connect to the local port of the SSH tunnel.

        Ok. That sounds reasonable. I just have to figure out how to make the SSH2 tunnel. Also not sure what you meant by connecting the the local port. I'm not really a programmer by trade so having to do a lot of research.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1156768]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2020-06-04 20:26 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (35 votes). Check out past polls.