I am trying to embed Apache SSHD Server in my Android application. Here is the code:
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(8022);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
sshd.setShellFactory(new ProcessShellFactory(new String[]{"/system/bin/sh", "-i", "-l"},
EnumSet.of(ProcessShellFactory.TtyOptions.ONlCr)));
sshd.setCommandFactory(new ScpCommandFactory());
List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>();
namedFactoryList.add(new SftpSubsystem.Factory());
sshd.setSubsystemFactories(namedFactoryList);
sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
public boolean authenticate(String name, String password, ServerSession session) {
logger.debug("Name: " + name + ", Password: " + password);
return true;
}
});
sshd.start();
SCP connection works fine, but SSH keeps showing this after logon:
login as: *****
*****@192.168.1.22's password:
/system/bin/sh: No controlling tty: open /dev/tty: No such device or address
/system/bin/sh: can't find tty fd
/system/bin/sh: warning: won't have full job control
*****@android:/ $
After this, I can't type into console, there is no reaction. Does anybody know how to solve this problem? Alternatively, is there any other way how to embed SSH server in my application?
Thank you in forward for any help.
Best Regards Milan