I am developing app like sshdroid.
i want to open ssh connection on android os, and i want to connect app from pc.
I used JSCH lib , but this lib is used to connect android to pc. and my requirement is pc to android, any one know any lib or any source code is available.
I already tried.
connectbot.(it is unmaintained lib).
JSCH lib (it is connect android to pc).
SSHelper_source (not help to me).
SSHJ ( tried not helpful).
public void startSSHServer() {
int port = 8888;
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(port);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(
"src/test/resources/hostkey.ser"));
sshd.setSubsystemFactories(Arrays
.<NamedFactory<Command>> asList(new SftpSubsystem.Factory()));
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setShellFactory(new ProcessShellFactory(new String[] { "/system/bin/sh", "-i", "-l" })); // necessary if you want to type commands over ssh
sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
@Override
public boolean authenticate(String u, String p, ServerSession s) {
return ("sftptest".equals(u) && "sftptest".equals(p));
}
});
try {
sshd.start();
} catch (IOException e) {
e.printStackTrace();
}
}
Answer from amard Developer. (Thanks amar to given proper answer)
If you get below error
Error:Execution failed for task >
':app:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES File1: /home/yogesh/.gradle/caches/modules-2/files-2.1/org.apache.mina/mina-core/2.0.2/e365a84cc76a64bf1508af83da0ea852c35e79c8/mina-core-2.0.2.jar File2: /home/yogesh/.gradle/caches/modules-2/files-2.1/org.apache.sshd/sshd-core/0.6.0/2b9a119dd77a1decec78b0c511ba400c8655e96e/sshd-core-0.6.0.jar
then try using this in your apps build.gradle to solve above exception.
apply plugin: 'com.android.model.application'
model {
android {
...
}
android.packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}