LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Telnet through SSH port

Hello pRoFiT,

Thank you for contacting National Instruments!  I am a little bit confused from your previous post.  Do you still have questions on this issue or were you able to get everything straightened out?  Please just let us know so we can try to help answer any questions that you may still have. 
Thanks!
Bob H
Applications Engineer
National Instruments
0 Kudos
Message 21 of 25
(4,346 Views)

Hello,

 

I have been reading this thread  but I still have some doubts.  I'm doing an application to control a Burn In Station for IP Cameras.  During the Burn IN Period I want to automatically connect to the camera ssh server and run an embbeded self test, then read and report the results to the operator.  Apparently the only way to do it is using plink port forwarding and Telnet vi to send the data.  One more thing, my session has to be interactive because the self test will request the user to answer some questions during the execution so I need to open the session read and write a few times and then close.

Can somebody post or direct me to a simple example on how to achieve that?

 

 

0 Kudos
Message 22 of 25
(4,088 Views)

First off, not that the telnet vi is bad. Just costly for the extra network toolkit. So i've written an automation app that does UPNP calls to my cameras. And similar to what you need telnet to my network switch to get mac locations on the network.

 

Simple tcp connections should work for you. A tcp connection made to port 22 (the ssh port) and then a tcp read will probably return the login prompt from the SSH server. at that point you would only need to send a tcp write back with the login info. The only thing that may give you problems will be certificates from the SSH server....I know i only did telnet and did not have to worry about that. But i've noticed some SSH or SCP connections to linux based devices will ask if you want to except the certificate.

 

What i would do is open the TCP read/write examples in labview and change the port to 22 and the IP to the IP of your camera.

 

 

Not sure what you will get with this 🙂 

 

I modified the example file to loop forever until the network errors out or you hit stop. It should connect to whatever IP you type in. Put in your cameras IP and then hit run, it should display the returned data from the camera. You may get a Login prompt. If it just times out with no data maybe you need a return key sent first? I would guess you would get a login prompt and then you would need to send your user name [return] and you password [return]. you will need to wait for each response. I did not set the type of read for tcp but the default is standard (meaning it will read the bytes you tell it to read) you may be able to set this to CRLF and not put a byte count in. This would return data for every line feed it reads. which in a linux embeded invironment over SSH you may be getting Line feeds for every command sent.

 

Look through the TCP examples and you will see how to write back to the TCP port as well. Its as simple as the read. Almost like talking to a serial port 🙂 text in, text out.

 

simpleread.png

 

p.s. this is the new 2009 snipet format. So if you have 2009 you can drag this from the web site onto a blank vi.

 

hope this helps you.

 

edit: p.p.s. it did not keep my default 22 port. so you need to change that. and you may want to add a lower timeout for the connect. its 6 seconds now. 🙂

Message Edited by pRoFiT on 08-27-2009 11:15 PM
- A minute saved is a Minute earned!
0 Kudos
Message 23 of 25
(4,074 Views)

Thank you Profit for your help but it didn't work for me.  The .vi stops running due to an error 56 in the Read vi.  I think it is because of the timeout period.  I change a few numbers there but I still have the same result (sooner or later ).  I'm only receiving the following string:

 

SSH-1.99-OpenSSH_4.3p2

 

To be honest with you I'm not a literate on this communications protocols and I don't know what to do.

 

Regards

0 Kudos
Message 24 of 25
(4,044 Views)

After doing some testing, I'm 99% sure that NI is incorrect when they state that you can use plink to connect to an SSH server via telnet in the internet conenctivity toolkit (or tcp for that matter).

 

Here is the reason:

 

Telnet is a text-based connection on a port (typically 23), SSH is similair to telnet but it is an encrypted connection requiring the SSH protocol.  What Plink does is set up a port fowarding between your local machine and a destination HOWEVER, what plink does not do is convert telnet protocol to SSH protocol.  If you set up a plink and then use Putty to connect to your local plink, you will see that if you connect with the "telnet" box checked,  you get "SSH-2.0-OpenSSH_5.2 Protocol mismatch." or something similair, this will happen in putty or labview or any other telnet client.  If you now try connecting with the "SSH" protocol box checked, everything works fine, this is because you are now communicating "in ssh" so to speak - encrypted. Labview, as far as I can tell, gives you no mechanism to communicate in SSH and plink only does port forwarding, it does not translate a TCP or Telnet connection to an SSH procotol.

 

The example code that was given earlier where someone was connecting to cameras on port 22 with TCP was using a device (the camera) that was likely not actually using SSH protocol on its host port (even though the port was 22, it does not necessarily have to be a true SSH protocol server).  In any of the cases where you need to connect to an actual SSH server, I dont suspect that anything so far listed in this thread will assist you. I will update if I find another solution.

0 Kudos
Message 25 of 25
(3,427 Views)