Hello All, I am trying to setup a SSH Server using Apache SSHD. I tried using the quick SSH server setup as suggested in the Apache SSHD documentation:
http://mina.apache.org/sshd/embedding-sshd-in-5-minutes.html My code : import java.io.IOException; import java.io.OutputStream; import java.net.ServerSocket; import org.apache.mina.core.session.IoSession; import org.apache.sshd.SshServer; import org.apache.sshd.common.AbstractSessionIoHandler; import org.apache.sshd.common.keyprovider.FileKeyPairProvider; import org.apache.sshd.server.PasswordAuthenticator; import org.apache.sshd.server.SessionFactory; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.apache.sshd.server.ShellFactory.Shell; import org.apache.sshd.server.command.ScpCommand; import org.apache.sshd.server.command.ScpCommandFactory; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; import org.apache.sshd.server.shell.ProcessShellFactory; public class Main { public static SshServer sshd = null; public static SessionFactory sessFactory =null; public static IoSessionImpl ioSession = null; public static ProcessShellFactory shell = null; public static void main(String[] args) throws InterruptedException, IOException { SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(22); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); //sshd.setShellFactory(new ProcessShellFactory(new String[] { "/usr/bin/login", "-f", "-h", "localhost", "$USER", "/bin/sh", "-i" })); sshd.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh", "-i", "-l" })); //sshd.setPasswordAuthenticator(new PAMPasswordAuthenticator()); sshd.setPasswordAuthenticator(new PasswordAuthenticator() { public Object authenticate(String username, String password) { return (username != null && username.equals(password)) ? username : null; } }); sshd.start(); } } I am trying to do this on my PC, config is : > Windows XP > Pentium 4 The problem is that when I try to login using PuTTY, the shell exits after the prompt for username and password !! I tried debugging this, I saw that it comes to the authenticate procedure, after which it the PuTTY shell exits without any error message. Any help will be greatly appreciated. Thanks & Regards, Girish. S. Sadhani
