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

后端 未结 2 1954
傲寒
傲寒 2021-02-10 15:26

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:58

    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

提交回复
热议问题