Run ssh command in labview

does anyone knows how to run an ssh command in labview?
I know how to run some linux commands in labview but my problem is when I try to run an ssh command ...
thks
JP

Unfortunetly, I don't know how to script in a password for ssh. SSH closes the stdin and re-opens the tty that you are logged in at. This is actually a security feature. As well as a way to send stdin to remote programs (otherwise your password would get in the way.)
If you don't need to ssh to a remote host, and you want to chmod something on the localhost, you could use sudo instead. With sudo you can specify certain users (or all users) to run certain commands. (so you could make a shell script to chmod for you).
I don't know your exact needs, but I think that a public/private keypair could still work. In your authorized keys file on your "root" account, you can even specify that "this public key does not get shell access, and can only execu
te this one command." This would probably be the most secure method. But it requires the user to have the correct private key as well.
If you know that won't work for some reason, then maybe you could setup a inetd process that will execute a command whenever someone connects to a certain port (then you could use LabVIEW's TCP VIs).
Or, if you are not connecting remotely, you could setuid your LabVIEW executable (A VERY BAD IDEA!).
Also, it is possible to script "telnet." It would of course transmit your root password as plaintext, but trying to script your ssh session would also embed your password in your LabVIEW VI. Out internet toolkit for LabVIEW has some helpful telnet VIs.
May I ask why you want to chmod something on a remote system that requires root? Sounds like maybe you should create a LabVIEW application on the remote side that acts as a daemon (running as root) and accepts connections and commands and does the chmodding for you.
-Duffey

Similar Messages

  • Running ssh command from java and then answering password prompt

    Hi,
    I have a situation that has not solved yet. I am running ssh command from unix terminal without any problem, and then i enter password.
    For example :
    [oracle@fuata]:/export/home/oracle> ssh -N [email protected] -L 9901:127.0.0.1:9999
    Password:
    It is working. I have question that how can i perform this in java? I am thinking that i can run ssh command by using Runtime Class, it is ok. But how can i answer the password? I am a bit confused. Is there any example looks like this?
    Thanks for responses.

    futi wrote:
    Thanx. Firstly i insisted to do this without jsch but actually this is harder than jsch. I edit some of code pieces PortForwardingL.java and could run it. It works problem-free. Could you say why you "insisted" on this approach. It can't be for speed+ since jsch is very fast. It can't be for portability+ since jsch is portable but the use of Runtime.exec() requires the installation of ssh software. It can't be because of limitations+ since jsch is a fully featured library. It can't be for security+ since jsch is secure. It can't be for ease of use+ since jsch is much easier to use than ssh with Runtime.exec(). Unless it's a licensing issue, it can't be for commercial+ reasons since jsch is free. The only reason I can think of why one would "insisted" on this approach is if it is for some college project.

  • Total nube to jws, need to run ssh command via web or jws?

    Ok So we had a developer that created this application that can basically run ssh commands via jws I believe. Unfortunately he is no longer here. I am wondering how you do this? I know tha commands that are already set up, but I have no idea how to implement it into my project.
    I am using Struts 2, Java 5, Weblogic 9.2, Spring
    Thanks
    orozcom

    Have a look at:
    http://www.jcraft.com/jsch/
    basically you'd need a small webstart client to wrap something like the above library. Best thing is to try with a standalone java client first. Once that is working have a look at turning it into a webstart app.

  • Running ssh command in a java application

    Hi there!
    I am trying to run a ssh command from a java application cause I need to store the result.
    Actually I can run this command in the cygwin shell so I need to open the shell and run the command, all trough java.
    so, what my process needs to do is:
    1) open the cmd
    2) run C:\cygwin\cygwin.bat
    3) execute the ssh command
    ssh -l fip-user ipdb fip 42704) print the result of the ssh command.
    Note that the cygwin opens in the same command line window and so will print it's result to the same process inputstream
    Message was edited by:
    RBervini

    Use "Runtime.getRuntime().exec()" to execute the SSH program,
    and you can then get the output of the SSH program
    via the getInputStream() method on the returned Process object.
    Note: there are many pitfalls with this. In particular, most people don't know
    they should create separate threads to drain the input/output pipes.
    See this excellent classic article http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    on how to do it right.

  • Running SSH command after auth

    To save some time, I know about sshrc...
    What I am trying to do is run a script (or file or whatever) after a user is authenticated... This is extremely simple with the use of sshrc, but my users are going to be connecting with the -N argument:
    -N     Do not execute a remote command.  This is useful for just forwarding ports (protocol version 2 only).
    When users are connecting with that, my script does not run...
    Is there an alternate way to run a script?
    By the way... The reason I'm doing this is because I am running a SOCKS server and the users are set to /bin/false.

    Well I am trying to run a script after ssh authentication when the client is connecting with the -N flag....
    I am hosting a socks proxy server, and I want to prevent simultaneous logins with the same user. The proxy users all have the shell set to /bin/false and their default group set to 'proxy '.
    Basically, what I want to do is to disconnect both connections when I detect simultaneous logins...

  • Error while transferring file :: Error while issuing ssh command.

    Hi All,
    I am having a JSP based website application.
    I am getting the following exception in my logs.
    [ERROR] 05/04/2007 03:43:44 - Error while transferring file :: Error while issuing ssh command.
    java.net.ConnectException: Connection timed out
                at java.net.PlainSocketImpl.socketConnect(Native Method)
                at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
                at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
                at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
                at java.net.Socket.connect(Socket.java:464)
                at java.net.Socket.connect(Socket.java:414)
                at java.net.Socket.<init>(Socket.java:310)
                at java.net.Socket.<init>(Socket.java:125)
                at com.sshtools.j2ssh.net.SocketTransportProvider.<init>(Unknown Source)
                at com.sshtools.j2ssh.net.TransportProviderFactory.connectTransportProvider(Unknown Source)
                at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
                at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
                at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
                at com.novartis.util.DataExporter.transportFile(DataExporter.java:127)
                at com.novartis.util.DataExporter.export(DataExporter.java:101)
                at com.novartis.businessmanagers.SandosSignupManagerPojoImpl.export(SandosSignupManagerPojoImpl.java:103)
                at com.novartis.util.DataExportJob.process(DataExportJob.java:48)
                at com.novartis.util.ExclusiveJob.execute(ExclusiveJob.java:35)
                at org.quartz.core.JobRunShell.run(JobRunShell.java:191)
                at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)Any help would be appreciated.
    Thanks.

    This means that the SSH server you're trying to connect to isn't listening. Is the SSH server running? Are you trying to connect to the right machine?

  • My process interrupts when I hibernate while running SSH, what to do?

    Hi!
    I have a low-end box (512 MB RAM, 1 processor, 15 GB hard disk, 2 TB / month bandwith, Arch Linux) , and I connect to it by SSH. Currently I use it for uploading / downloading stuff, and video encoding. My problem is when I transcode the video by FFmpeg - it takes long time, about 8 hours - and when I hibernate my home machine, the FFmpeg process aborts on the remote box and the resulting video file will be truncated. What can I do to avoid this annoyance?

    When your client hibernates, the ssh connection times out and the remote's ssh client session is terminated. This sends a SIGHUP to all the child processes, to which the default reaction is termination. The 2 most common ways to deal with this are either the 'nohup' command (`man 1 nohup`) (which I personally dislike and try to avoid because its default behavior is to send stdout/err to 'nohup.out'), or running the commands in a tmux/screen session, which is something you should learn/know about either way. The moment you start using ssh is the moment you lose every right to argue against screen/tmux (even for local work they're perfectly useful tools)
    My personal favourite is tmux.
    Last edited by Blµb (2014-03-24 11:25:03)

  • Running ssh from within java program

    Hi!
    I am trying to start ssh from within java e.g.:
    Runtime run = Runtime.getRuntime();
    Process pro = run.exec("ssh -l xx 12.12.12.12");
    But it complains:
    socket: Operation not permitted
    ssh: connect to host 12.12.12.12 port 22: Operation not permitted
    Running ssh from the command prompt works just fine. It's run on win xp.
    What is the problem, and how can I avoid it?
    Endre

    Afraid not. I think maybe it's related to security permissions, but I am really not sure. If you can help, I would appreciate it.
    - Endre

  • Java running host command - moved from PL/SQL forums

    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE 11.1.0.6.0 Production
    TNS for HPUX: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    Hi,
    I am not familiar with Java setting in Oracle
    I have a a stored procedure that call a java program to execute host command like
    ssh user1@localhost '/home/user1/someprogram'
    if we execute this directly using PuTTY
    we can do the following with no problem
    su - oracle
    ssh user1@localhost '/home/user1/someprogram'
    but when we execute the stored procedure,
    we have to do
    */usr/bin/ssh* user1@localhost '/home/user1/someprogram'
    does anybody where to set the path or environment to make the java know the path correctly.
    thanks
    ps:. this is happen after we recently upgraded our Oracle from 9.2.0.8 to 11.1.0.6

    pgoel wrote:
    You said,
    a stored procedure that call a java program to execute host command like ssh user1@localhost '/home/user1/someprogram'SP -calls> Java Program (JP) -runs> ssh user1@localhost '/home/user1/someprogram'. is that right? I presume locahost is a database server.correct
    this is the stored procedure
    CREATE OR REPLACE PROCEDURE host_command (p_command  IN  VARCHAR2)
      AS LANGUAGE JAVA
      NAME 'Host.executeCommand (java.lang.String)';and this is the java
    create or replace and compile java source named host as
    import java.io.*;
    public class Host {
      public static void executeCommand(String command) {
        try {
          String[] finalCommand;
          if (isWindows()) {
            finalCommand = new String[4];
            // Use the appropriate path for your windows version.
            finalCommand[0] = "C:\\windows\\system32\\cmd.exe";  // Windows XP/2003
            //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe";  // Windows NT/2000
            finalCommand[1] = "/y";
            finalCommand[2] = "/c";
            finalCommand[3] = command;
          else {
            finalCommand = new String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
          final Process pr = Runtime.getRuntime().exec(finalCommand);
          pr.waitFor();
          new Thread(new Runnable(){
            public void run() {
              BufferedReader br_in = null;
              try {
                br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                String buff = null;
                while ((buff = br_in.readLine()) != null) {
                  System.out.println("Process out :" + buff);
                  try {Thread.sleep(100); } catch(Exception e) {}
                br_in.close();
              catch (IOException ioe) {
                System.out.println("Exception caught printing process output.");
                ioe.printStackTrace();
              finally {
                try {
                  br_in.close();
                } catch (Exception ex) {}
          }).start();
          new Thread(new Runnable(){
            public void run() {
              BufferedReader br_err = null;
              try {
                br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
                String buff = null;
                while ((buff = br_err.readLine()) != null) {
                  System.out.println("Process err :" + buff);
                  try {Thread.sleep(100); } catch(Exception e) {}
                br_err.close();
              catch (IOException ioe) {
                System.out.println("Exception caught printing process error.");
                ioe.printStackTrace();
              finally {
                try {
                  br_err.close();
                } catch (Exception ex) {}
          }).start();
        catch (Exception ex) {
          System.out.println(ex.getLocalizedMessage());
      public static boolean isWindows() {
        if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
          return true;
        else
          return false;
    Where does Java Progarm reside? On the database server filesystem OR within the Database itslef. within the Database itslef.
    Edited by: HGDBA on Mar 11, 2011 1:50 PM

  • Mac os X - ssh command

    I am trying to build a little applications and want to be able to use the unix shell to run ssh
    so i can run the ssh command and read and write to the connection.
    I tried to use the Runtime with the exec command but i get an error saying ssh is unknown command, but i can use commands like "ls" and get the output
    any ideas?
    cheers

    If you're at a terminal window and you can type ssh and it works, then ssh is in your PATH. However, the environment you get when you use Runtime.exec is not the same as in a terminal window. It won't have run all the .zshrc, etc. files that you get with the terminal, so the PATH is different.
    You'll need to either specify the full path, like runtime.exec("/usr/bin/sss blah") or else exec a shell script that sources the proper .zshrc or whatever files.
    Note, however, that you still might have problems. ssh might be one of those programs that only accepts input from a terminal, not from arbitrary pipes or streams.

  • Cannot start NodeManager Remotly (Via SSH Commands)

    Hi all,
    we are going to start the node manager of one of the cluster servers via SSH command.
    But it is not starting. We can start it directly by log in to that server and run startNodemanager.sh script.
    What is the issue?
    Thanks,
    Nir

    Hi are you able to start Node manager using following WLST Command :
    startNodeManager(verbos='true',NodeManagerHome='$WL_HOME/common/nodemanager',ListenPort='<PortNo>',ListenAddress='<HostName')
    And also can check NodeManager Log files for errors .
    Regards
    Edited by: TheKop88 on Jun 5, 2013 6:13 PM

  • SSH + Command + Quit?

    I am writing a shell script to ssh to a range of laptops/desktop and run some commands which is easy enough:
    ssh -l USER 1.2.3.4 echo "hello world"
    But if I run a command that takes a while to run, for example "softwareupdate -i -a" to download and install all software updates, I have to wait for the update process to complete before my machine will ssh to the next laptop/computer and run my chosen command.
    How can I ssh to a computer, send it a command and then disconnect not having to wait for the command to finished executing, just let it run?

    If the destination host is a Unix machine, won't adding an & at the end of the command string work? This should normally send the command to be executed in the background, disconnecting from the control terminal.

  • How to execute multiple SSH commands using Ganymed

    I try to use Ganymed SSH to send and receive commands to/from the SSH server.
    However Ganymed example shows only sending one single SSH command to the SSH server.
    Does anybody know how to send and receive multiple commands to/from SSH server?

    I tried many times and it did not work. Please help.
    The output is this :
    Last login: Tue Oct  6 23:05:10 2009 from 192.168.1.4
    /bin/ls -aldf -k[root@linux ~]# /bin/ls -aldf -kExit status : nullI enclose the
    import ch.ethz.ssh2.ChannelCondition;
    import ch.ethz.ssh2.Connection;
    import ch.ethz.ssh2.KnownHosts;
    import ch.ethz.ssh2.Session;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    public class TestClient01 implements Runnable {
        static final String knownHostPath = "~/.ssh/known_hosts";
        static final String idDSAPath = "~/.ssh/id_dsa";
        static final String idRSAPath = "~/.ssh/id_rsa";
        private String host = "192.168.1.2";
        private String username = "root";
        private String password = "1234567";
        private KnownHosts database = new KnownHosts();
        private OutputStreamWriter writer = null;
        private Connection conn = null;
        private Session sess = null;
        public void writeCommand(String s) {
            try {
                writer.write(s);
                writer.flush();
            } catch(Exception ex) {}
        public void close() {
            if (writer==null) return;
            try {
                writer.close();
                sess.close();
                conn.close();
            } catch(Exception ex) {}
            if (writer!=null) writer = null;
        public void run() {
            try {
                conn = new Connection(host);
                conn.connect();
                boolean isAuthenticated = conn.authenticateWithPassword(username, password);
                if (!isAuthenticated) throw new IOException("Authentication failed.");
                sess = conn.openSession();
                new Thread(new SyncPipe(sess.getStderr(), System.err)).start();
                new Thread(new SyncPipe(sess.getStdout(), System.out)).start();
                sess.requestPTY("bash");
                sess.startShell();
                writer = new OutputStreamWriter(sess.getStdin(), "utf-8");
                writeCommand("/bin/ls -al");
                writeCommand("df -k");
                sess.waitForCondition(ChannelCondition.CLOSED | ChannelCondition.EOF |
                        ChannelCondition.EXIT_STATUS, 10000);
                System.out.println("Exit status : " + sess.getExitStatus());
            } catch (Exception e) {
                e.printStackTrace(System.err);
                System.exit(2);
        public static void main(String[] args) throws Exception { new TestClient01().run();}
        class SyncPipe implements Runnable {
            String CVS_VERSION = "$Revision: 1.1 $ $Id: SyncPipe.java,v 1.1 2008-09-30 03:47:56 sabre Exp $ ";
            private final byte[] buffer_;
            private final OutputStream ostrm_;
            private final InputStream istrm_;
            private boolean closeAfterCopy_ = false;
            public SyncPipe(InputStream istrm, OutputStream ostrm) { this(istrm, ostrm, 4096);}
            public SyncPipe(InputStream istrm, OutputStream ostrm, int bufferSize) {
                if (istrm == null) throw new IllegalArgumentException("'istrm' cannot be null");
                if (ostrm == null) throw new IllegalArgumentException("'ostrm' cannot be null");
                if (bufferSize < 1024) throw new IllegalArgumentException("a buffer size less than 1024 makes little sense");
                istrm_ = istrm;
                ostrm_ = ostrm;
                buffer_ = new byte[bufferSize];
            public void handleException(IOException e) { e.printStackTrace();}
            public SyncPipe setCloseAfterCopy(boolean closeAfterCopy) {
                closeAfterCopy_ = closeAfterCopy;
                return this;
            public void run() {
                try {
                    for (int bytesRead = 0; (bytesRead = istrm_.read(buffer_)) != -1;)
                        ostrm_.write(buffer_, 0, bytesRead);
                    ostrm_.flush();
                    if (closeAfterCopy_) ostrm_.close();
                } catch (IOException e) { handleException(e);}
    }

  • -bash: ssh: command not found = no ssh?

    Hi all,
    Sorry if this isn't the right category - this seemed to be the best fit.
    I'm having trouble with SSH.
    I've used ssh in the past (back when I was running Leopard) but I've never had all that much use for it. Today, however, I opened up terminal to SSH to an iMac on my local network, and got the following back:
    -bash: ssh: command not found
    Having a look around on the internet, somebody else said that they got this message but was still able to see the SSH manual by typing ssh man. However, when I tried this I just got "command not found" again.
    Any ideas?
    Thanks in advance,
    BrutalSpoon.

    Do you remember if you modified .profile or .bash_profile when you installed mysql?
    I guess you could search for the file that has the modification
    /usr/bin/grep /usr/local/mysql/bin $HOME/.[a-z]*
    Once you find the file, edit that file and put a dollar sign infront of PATH
    /usr/bin/nano /name/of/file/with/mysql/bin/in/it
    The entry you want to fix most likely looks like
    export PATH=PATH:/usr/local/mysql/bin
    you want to change this to
    export PATH=$PATH:/usr/local/mysql/bin
    The problem is the missing dollar sign $ which would cause the current PATH to be substituted before the addition of /usr/local/mysql/bin.
    Once the change is made, quit Terminal and relaunch it. The corrected PATH should now work.
    NOTE: If you do not want to use nano you could use TextWrangler (via File -> Open Hidden...), or Smultron (via File -> Open Hidden...). You should be able to find these GUI based text editors via <http://versiontracker.com>.
    Good luck.

  • Urgent!! running system command in java

    i am trying to run system command(windows) in java. I am getting
    exception as java.io.IOException: CreateProcess: c:\dir
    Please Help.
    Here is the code
    import java.io.*;
    public class RunCommand {
    public static void main(String[] args) {
    try
    //run dir command
    Process p = Runtime.getRuntime().exec("c:\\dir");
    BufferedReader stdInput=new BufferedReader(new
    InputStreamReader(p.getInputStream()));
    BufferedReader stdError =new BufferedReader(new
    InputStreamReader(p.getErrorStream()));
    //read the output
    System.out.println("here is the output:\n");
    while((s=stdInput.readLine())!=null){
    System.out.println(s);
    System.out.println("here is the error if any");
    while((s=stdError.readLine())!=null){
    System.out.println(s);
    System.exit(0);
    }//end try
    catch (IOException e)
    System.out.println("exception Happened" );
    e.printStackTrace();
    System.exit(-1);

    It works fine if you replaceProcess p = Runtime.getRuntime().exec("c:\\dir");withProcess p = Runtime.getRuntime().exec("cmd /c dir");And don't forget to define your s variable.

Maybe you are looking for

  • A word document as a pagelink in i DVD

    Hi, maybe a stupid question..but how can I link a word document(or pages) with only text in it to a menu button in i DVD? I mean when hit the button you see the text (couple of A4 pages) QT and pictures are no problem but I can't drag and drop just t

  • IPad (gen 1) keeps crashing

    Hi, Randomly, but more and more often my original 32 GB WiFi iPad crashes. Totally unforced. No matter what I do. I finally was able to catch it on cam today. On this clip it first crashes with multiple stripes on screen, which is most common, then l

  • Desktop turns to blue every time I change user

    Hi, I have Yosemite installed on my MacBook Pro late 2013 and every time that I change from one user to other the picture that I had choose for desktop turns back to solid blue. This is quite annoying :-( and it also happened when it had Mavericks on

  • No receivables and payables are updated in Profitcenter accounting

    Dear All, No Account Receivables and payables are getting updated In profit center accounting. In 3KEH we need to maintain only the balance sheet accounts? or P&L a/c's also needs to be maintained? Please advice, Rgds, Kumar.

  • How to read a MessageTextInput in an advancedSearch region

    Hi, I am new to OAF and i am working in a Advanced Search Page. There are 4 criteria with which the Search happens and there are 4 messageTextInputs for taking input. Can anyone tell me how to take handle of these textinputs? I tried OAPageLayoutBean