How to run and display the result of a shell command ssh with JSch?

后端 未结 2 1324
逝去的感伤
逝去的感伤 2021-02-10 15:16

I try to use the library JSch - Java Secure Channel make an ssh connection in my Android app, it works.

Now I would like to execute a command and retrie

2条回答
  •  广开言路
    2021-02-10 15:54

    As far as I am aware JSch is the only real option.

    I have found that Jsch errors tend to take some digging. But in the first instance you will want to catch and print out the errors as a minimum.

    try{ 
        JSch jsch = new JSch();
        Session session = jsch.getSession(username, hostname, port);
        ... omitted 
     } catch (Exception e) {
         System.out.println(e) 
     }
    

    also have a look a the example code on the site

提交回复
热议问题