3

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

Milan Fabian
  • 154
  • 4
  • 13
  • Any news on this ? I'm implementing an ssh server for android, and I've the same issue. – Luca D'Amico May 01 '14 at 21:51
  • I already gave up trying to run Apache SSHD on Android, now I use dropbear binary. – Milan Fabian May 12 '14 at 08:01
  • It could be a SELinux issue. Since SEL introduction, the root/su behavior has changed radically. Extremely developer unfriendly. Check this out: http://su.chainfire.eu/ – not2qubit May 22 '14 at 17:55

1 Answers1

0

I worked around this problem by adding the -T switch to ssh. I still get the warnings, but at least I can type into the terminal.