X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.core%2Fsrc%2Forg%2Fargeo%2Fsync%2Ffs%2FSshSync.java;h=7fe6670c9ef7627ad949b65ae0fdbbdb6cbca23e;hb=5f1074b1658db47705b0b532099e19ba918c5745;hp=43af4503678213a37e7872d649ea6ebf106e3185;hpb=d6bb3d3e0643c410ecd3ca1d4d88ae412697f258;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.core/src/org/argeo/sync/fs/SshSync.java b/org.argeo.core/src/org/argeo/sync/fs/SshSync.java index 43af45036..7fe6670c9 100644 --- a/org.argeo.core/src/org/argeo/sync/fs/SshSync.java +++ b/org.argeo.core/src/org/argeo/sync/fs/SshSync.java @@ -27,8 +27,8 @@ import org.apache.sshd.client.channel.ClientChannelEvent; import org.apache.sshd.client.config.keys.ClientIdentityLoader; import org.apache.sshd.client.future.ConnectFuture; import org.apache.sshd.client.session.ClientSession; -import org.apache.sshd.client.subsystem.sftp.SftpFileSystem; -import org.apache.sshd.client.subsystem.sftp.SftpFileSystemProvider; +import org.apache.sshd.client.subsystem.sftp.fs.SftpFileSystem; +import org.apache.sshd.client.subsystem.sftp.fs.SftpFileSystemProvider; import org.apache.sshd.common.config.keys.FilePasswordProvider; import org.apache.sshd.common.util.io.NoCloseInputStream; import org.apache.sshd.common.util.io.NoCloseOutputStream; @@ -40,7 +40,7 @@ public class SshSync { try (SshClient client = SshClient.setUpDefaultClient()) { client.start(); - boolean osAgent = false; + boolean osAgent = true; SshAgentFactory agentFactory = osAgent ? new UnixAgentFactory() : new LocalAgentFactory(); // SshAgentFactory agentFactory = new LocalAgentFactory(); client.setAgentFactory(agentFactory); @@ -55,15 +55,15 @@ public class SshSync { System.out.print(keyPath + ": "); Scanner s = new Scanner(System.in); String password = s.next(); - KeyPair keyPair = ClientIdentityLoader.DEFAULT.loadClientIdentity(keyPath, - FilePasswordProvider.of(password)); - sshAgent.addIdentity(keyPair, "NO COMMENT"); +// KeyPair keyPair = ClientIdentityLoader.DEFAULT.loadClientIdentity(keyPath, +// FilePasswordProvider.of(password)); +// sshAgent.addIdentity(keyPair, "NO COMMENT"); } - List> identities = sshAgent.getIdentities(); - for (Map.Entry entry : identities) { - System.out.println(entry.getValue() + " : " + entry.getKey()); - } +// List> identities = sshAgent.getIdentities(); +// for (Map.Entry entry : identities) { +// System.out.println(entry.getValue() + " : " + entry.getKey()); +// } ConnectFuture connectFuture = client.connect(login, host, port); connectFuture.await(); @@ -143,21 +143,4 @@ public class SshSync { } - static void openShell(ClientSession session) { - try (ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL)) { - channel.setIn(new NoCloseInputStream(System.in)); - channel.setOut(new NoCloseOutputStream(System.out)); - channel.setErr(new NoCloseOutputStream(System.err)); - channel.open(); - - Set events = new HashSet<>(); - events.add(ClientChannelEvent.CLOSED); - channel.waitFor(events, 0); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - session.close(false); - } - } }