Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Setup an SCPInfo object to hold the username, password, port:22 and ip.</p> <pre><code> List&lt;String&gt; commands = new ArrayList&lt;String&gt;(); commands.add("touch test1.txt"); commands.add("touch test2.txt"); commands.add("touch test3.txt"); runCommands(scpInfo, commands); public static void runCommands(SCPInfo scpInfo, List&lt;String&gt; commands){ try { JSch jsch = new JSch(); Session session = jsch.getSession(scpInfo.getUsername(), scpInfo.getIP(), scpInfo.getPort()); session.setPassword(scpInfo.getPassword()); setUpHostKey(session); session.connect(); Channel channel=session.openChannel("shell");//only shell channel.setOutputStream(System.out); PrintStream shellStream = new PrintStream(channel.getOutputStream()); // printStream for convenience channel.connect(); for(String command: commands) { shellStream.println(command); shellStream.flush(); } Thread.sleep(5000); channel.disconnect(); session.disconnect(); } catch (Exception e) { System.err.println("ERROR: Connecting via shell to "+scpInfo.getIP()); e.printStackTrace(); } } private static void setUpHostKey(Session session) { // Note: There are two options to connect // 1: Set StrictHostKeyChecking to no // Create a Properties Object // Set StrictHostKeyChecking to no // session.setConfig(config); // 2: Use the KnownHosts File // Manually ssh into the appropriate machines via unix // Go into the .ssh\known_hosts file and grab the entries for the hosts // Add the entries to a known_hosts file // jsch.setKnownHosts(khfile); java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload