@Test public void testSendFile() { SshClient client = new SshClient(); String source = "production/resources/script/provision/install_master.sh"; String dest = "/tmp/install_master.sh"; try { client.connect(sshInfo).sendFile(source, dest, true); } finally { client.close(); } }
public void sendFile(String source, String dest, boolean executable) { try { ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); try { tryConnect(channel); logger.debug("[{}] Send file {} to {}", sshInfo.getHost(), source, dest); channel.put(source, dest); if (executable) { channel.chmod(Integer.parseInt("755", 8), dest); } } finally { if (channel != null) { channel.disconnect(); } } } catch (Throwable t) { throw new RuntimeException(t); } }
SshClient { public void sendFile(String source, String dest, boolean executable) { try { ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); try { tryConnect(channel); logger.debug("[{}] Send file {} to {}", sshInfo.getHost(), source, dest); channel.put(source, dest); if (executable) { channel.chmod(Integer.parseInt("755", 8), dest); } } finally { if (channel != null) { channel.disconnect(); } } } catch (Throwable t) { throw new RuntimeException(t); } } }
SshClient { public void sendFile(String source, String dest, boolean executable) { try { ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); try { tryConnect(channel); logger.debug("[{}] Send file {} to {}", sshInfo.getHost(), source, dest); channel.put(source, dest); if (executable) { channel.chmod(Integer.parseInt("755", 8), dest); } } finally { if (channel != null) { channel.disconnect(); } } } catch (Throwable t) { throw new RuntimeException(t); } }  }
SshClient { public void sendFile(String source, String dest, boolean executable) { try { ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); try { tryConnect(channel); logger.debug("[{}] Send file {} to {}", sshInfo.getHost(), source, dest); channel.put(source, dest); if (executable) { channel.chmod(Integer.parseInt("755", 8), dest); } } finally { if (channel != null) { channel.disconnect(); } } } catch (Throwable t) { throw new RuntimeException(t); } }  SshClient connect(SshInfo sshInfo); void close(); int runCommand(String label, File scriptFile); int runCommand(String label, File scriptFile, String... args); int runCommand(String label, String command); int runCommand(String label, String command, String... args); void sendFile(String source, String dest, boolean executable); }
SshClient { public void sendFile(String source, String dest, boolean executable) { try { ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); try { tryConnect(channel); logger.debug("[{}] Send file {} to {}", sshInfo.getHost(), source, dest); channel.put(source, dest); if (executable) { channel.chmod(Integer.parseInt("755", 8), dest); } } finally { if (channel != null) { channel.disconnect(); } } } catch (Throwable t) { throw new RuntimeException(t); } }  SshClient connect(SshInfo sshInfo); void close(); int runCommand(String label, File scriptFile); int runCommand(String label, File scriptFile, String... args); int runCommand(String label, String command); int runCommand(String label, String command, String... args); void sendFile(String source, String dest, boolean executable);  }