Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by perlfan (Vicar)
on Mar 03, 2016 at 21:08 UTC ( [id://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 http://unix.stackexchange.com/questions/80028/what-is-the-equivalent-of-telnet-localhost-25-with-ssh.

  • 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-26 02:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found