@Test public void shouldExecuteBackgroundCommand() throws IOException { SSHClient sshClient = fixture.setupConnectedDefaultClient(); sshClient.authPassword("jeroen", "jeroen"); File file = new File(temp.getRoot(), "testdir"); assertThat("File should not exist", !file.exists()); // TODO figure out why this does not really execute in the background. Session.Command exec = sshClient.startSession().exec("mkdir " + file.getPath() + " &"); exec.join(); assertThat("File should exist", file.exists()); assertThat("File should be directory", file.isDirectory()); SFTPClient sftpClient = sshClient.newSFTPClient(); if (sftpClient.statExistence("&") != null) { sftpClient.rmdir("&"); // TODO fail here when this is fixed } } }
@Override public SFTPClient create() throws IOException { checkConnected(); sftp = sshClientConnection.ssh.newSFTPClient(); return sftp; }
@Override public SFTPClient create() throws IOException { checkConnected(); sftp = sshClientConnection.ssh.newSFTPClient(); return sftp; }
@Override public SFTPClient create() throws IOException { checkConnected(); sftp = sshClientConnection.ssh.newSFTPClient(); return sftp; }
@Override public SFTPClient create() throws IOException { checkConnected(); sftp = sshClientConnection.ssh.newSFTPClient(); return sftp; }
@Override public SFTPClient create() throws IOException { checkConnected(); sftp = sshClientConnection.ssh.newSFTPClient(); return sftp; }
@Override public SFTPClient create() throws IOException { checkConnected(); sftp = sshClientConnection.ssh.newSFTPClient(); return sftp; }
@Override public SFTPClient create() throws IOException { checkConnected(); sftp = sshClientConnection.ssh.newSFTPClient(); return sftp; }
try { LocalSourceFile messageFile = new InMemoryTradeFile(message, refId); SFTPClient sftp = client.newSFTPClient(); sftp.put(messageFile, dest); sftp.close();
final SSHClient ssh = new SSHClient(); ssh.loadKnownHosts(); // or, to skip host verification: ssh.addHostKeyVerifier(new PromiscuousVerifier()) ssh.connect("localhost"); try { ssh.authPassword("user", "password"); // or ssh.authPublickey(System.getProperty("user.name")) final SFTPClient sftp = ssh.newSFTPClient(); try { sftp.get("test_file", "/tmp/test.tmp"); } finally { sftp.close(); } } finally { ssh.disconnect(); }