How to Continuously Communicate in a SSH Session Using LabVIEW?

Updated Dec 31, 2025

Reported In

Software

  • LabVIEW
  • JKI VI Package Manager

Issue Details

I want to automate SSH communication using LabVIEW.
The target device operates by receiving ASCII character commands sequentially while maintaining an SSH communication session. I tried using the PuTTY SSH Exec VI, which is available in the Functions Palette under Data Communication  >> Protocols >> SSH, but the SSH communication session gets disconnected after the first command and I'm unable to execute the follow up ASCII commands, which is causing issues.

putty interface.png
In the above screenshot, I sent gpascii, save and P0 command and get response from the connected device after each command.
LV interface.png
On the other hand, when I sent gpascii command using LabVIEW, only the first command work and I get the response but it will automatically exit. The second command save did not reach the device at all.

Could you please advise on how to maintain the SSH communication session? 

Solution

As of LabVIEW 2025, LabVIEW's native SSH function (OpenSSH Exec VI and PuTTY SSH Exec VI) can only send and receive a single session and it's not possible to keep it alive by default. 

If continuous communication with an SSH session is required, please review the following workarounds:

 

  • Use third-party addon for LabVIEW such as LIBSSH2 for LabVIEW Toolkit which can be downloaded via VI Package Manager. Note: support for this third-party addon is provided by Field R&D Services.
  • If you are looking to establish continuous communication with a Linux server through SSH, you can use the tmux command. tmux allows you to create several pseudo-terminals from a single terminal. It also decouples your programs from the main SSH terminal, protecting them from accidentally disconnecting. With the tmux command, you can detach your application from the main terminal, and it will continue to run safely in the background. For more information, please refer to the following documentation from RedHat: A beginner's guide to tmux. When using this approach, you need to consider the following:
    • To start your program and detach it, you can run tmux new-session -d -s <your_session_name> "your_application_name"
    • To send commands to your separate session you can execute: tmux send-keys -t <your_session_name> "<your_Query>" Enter
    • To read the response: tmux capture-pane -t <your_session_name> -p
    • To end the session and close the program in the background: tmux kill-server

You can use the following framework as a guide:

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.

 

  • If you can modify your application, consider adding TCP/IP communication so you can send commands to it via the TCP/IP functions available in LabVIEW. You can still use the OpenSSH Exec VI or PuTTY SSH Exec VI to start your program in the background and then use TCP/IP functions for sending requests and receiving replies.