public void onChannelOpen() throws SshException { try { sess.execCommand(command); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, e); } } };
protected void onClose() throws SshException { try { session.delPortForwardingL(localAddress, localPort); } catch (JSchException e) { throw new SshException("Failed to configure local port forward"); } finally { channelCount--; } } };
protected void onOpen() throws SshException { try { client = this.ganymedSshClient.connection.createSCPClient(); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, e); } }
public void onOpen() throws SshException { try { channel.connect(); home = channel.pwd(); } catch (JSchException e) { throw new SshException("Failed to open SFTP client.", e); } catch (SftpException e) { throw new SshException("Failed to get home directory.", e); } }
protected void onClose() throws SshException { try { session.delPortForwardingR(remotePort); } catch (JSchException e) { throw new SshException("Failed to configure remote port forward"); } finally { channelCount--; } } };
public SftpClient createSftpClient() throws SshException { try { ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); return new JschSftpClient(channel); } catch (JSchException e) { throw new SshException("Failed to open SFTP channel.", e); } }
protected void onOpen() throws SshException { try { connection.requestRemotePortForwarding(remoteHost, remotePort, localAddress, localPort); } catch (IOException e) { throw new SshException( "Failed to open remote port forward.", e); } }
public void decrypt(char[] passphrase) throws SshException { if (!kpair.decrypt(new String(passphrase))) { throw new SshException(SshException.INCORRECT_PASSPHRASE, "Incorrect passphrase, could not decrypt key."); } }
protected void onOpen() throws SshException { try { session.setPortForwardingL(localAddress, localPort, remoteHost, remotePort); channelCount++; } catch (JSchException e) { throw new SshException("Failed to configure local port forward"); } }
public void requestPseudoTerminalChange(int width, int height, int pixw, int pixh) throws SshException { int ret = library.ssh_channel_change_pty_size(channel, width, height); if (ret != SshLibrary.SSH_OK) { throw new SshException("Failed to change terminal size. Err:" + ret); } }
public void onOpen() throws SshException { try { client = new SFTPv3Client(session); } catch (IOException e) { throw new SshException("Failed to start SFTP client.", e); } }
protected void onOpen() throws SshException { try { localPortForwarder = connection.createLocalPortForwarder( localPort, remoteHost, remotePort); } catch (IOException e) { throw new SshException( "Failed to open local port forward.", e); } }
protected void onClose() throws SshException { try { connection.cancelRemotePortForwarding(remotePort); } catch (IOException e) { throw new SshException( "Failed to stop remote port forward.", e); } } };
protected void onClose() throws SshException { try { localPortForwarder.close(); } catch (IOException e) { throw new SshException( "Failed to stop local port forward.", e); } } };
protected void onOpen() throws SshException { try { session.setPortForwardingR(remoteHost, remotePort, localAddress, localPort); channelCount++; } catch (JSchException e) { throw new SshException("Failed to configure remote port forward"); } }
public void disconnect() throws SshException { if (!isConnected()) { throw new SshException(SshException.NOT_OPEN, "Not connected."); } authenticated = false; try { session.disconnect(); } finally { session = null; } }
public final void put(String remotePath, String mode, File localfile, boolean recursive) throws SshException { if (!localfile.exists()) { throw new SshException(SshException.IO_ERROR, localfile + " does not exist"); } if (!localfile.isFile() && !localfile.isDirectory()) { throw new SshException(SshException.IO_ERROR, localfile + " is not a regular file or directory"); } if (localfile.isDirectory() && !recursive) { throw new SshException(SshException.IO_ERROR, localfile + " is a directory, so recursive mode must be used."); } if ((remotePath == null) || remotePath.equals("")) { remotePath = "."; } // else { // if (localfile.isDirectory() && !Util.basename(remotePath).equals(localfile.getName())) { // remotePath += "/" + localfile.getName(); // } // } doPut(remotePath, mode, localfile, recursive); }
public final void put(String remotePath, String mode, File localfile, boolean recursive) throws SshException { if (!localfile.exists()) { throw new SshException(SshException.IO_ERROR, localfile + " does not exist"); } if (!localfile.isFile() && !localfile.isDirectory()) { throw new SshException(SshException.IO_ERROR, localfile + " is not a regular file or directory"); } if (localfile.isDirectory() && !recursive) { throw new SshException(SshException.IO_ERROR, localfile + " is a directory, so recursive mode must be used."); } if ((remotePath == null) || remotePath.equals("")) { remotePath = "."; } // else { // if (localfile.isDirectory() && !Util.basename(remotePath).equals(localfile.getName())) { // remotePath += "/" + localfile.getName(); // } // } doPut(remotePath, mode, localfile, recursive); }
/** * Check the <strong>Known Hosts File</strong> parent directory exists, * creating it if it does. * * @param configuration * @throws SshException */ public static void checkKnownHostsFile(SshConfiguration configuration) throws SshException { File file = getKnownHostsFile(configuration); if (!file.exists() && !file.getParentFile().exists() && !file.getParentFile().mkdirs()) { throw new SshException("Could not create configuration directory " + file + ". Check permissions."); } } }
/** * Check the <strong>Known Hosts File</strong> parent directory exists, * creating it if it does. * * @param configuration * @throws SshException */ public static void checkKnownHostsFile(SshConfiguration configuration) throws SshException { File file = getKnownHostsFile(configuration); if (!file.exists() && !file.getParentFile().exists() && !file.getParentFile().mkdirs()) { throw new SshException("Could not create configuration directory " + file + ". Check permissions."); } } }