Hi,
Attached code is used to start ssh server.
When I connect this sshserver using below commands, my Subsystem commands are
not invoked.
Logs on ssh server:
Oct 14, 2015 7:07:57 AM
org.apache.sshd.common.util.SecurityUtils$BouncyCastleRegistration run
INFO: Trying to register BouncyCastle as a JCE provider
Oct 14, 2015 7:07:58 AM
org.apache.sshd.common.util.SecurityUtils$BouncyCastleRegistration run
INFO: Registration succeeded
Oct 14, 2015 7:08:05 AM org.apache.sshd.server.session.ServerSession <init>
INFO: Server session created from /10.1.2.60:55310
=====overture password::343434
Oct 14, 2015 7:08:10 AM org.apache.sshd.server.session.ServerUserAuthService
process
INFO: Session overture@/10.1.2.60:55310 authenticated
Logs on ssh client:
ssh [email protected] -p 8383
Password authentication
Password:
shell request failed on channel 0
This email and attachments may contain privileged or confidential information
intended only for the addressee(s) indicated. The sender does not waive any of
its rights, privileges or protections respecting this information. If you are
not the named addressee, an employee, or agent responsible for sending this
message to the named addressee (or this message was received by mistake), you
are not authorized to read, print, retain, copy or disseminate this message or
any part of it. If received in error, please notify us immediately by e-mail,
discard any paper copies and delete all electronic files of the email.
Computer viruses can be transmitted via email. The recipient should check this
email and any attachments for viruses. Email transmission cannot be guaranteed
to be secured or error-free as information could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or contain viruses. The sender
accepts no liability for any damage caused by any transmitted viruses or errors
or omissions in the contents of this message.
Overture Networks, Inc. 637 Davis Drive, Morrisville, NC USA 27560
www.overturenetworks.com
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.common.Cipher;
import org.apache.sshd.common.KeyPairProvider;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.cipher.ARCFOUR128;
import org.apache.sshd.common.cipher.ARCFOUR256;
import org.apache.sshd.common.io.IoServiceFactoryFactory;
import org.apache.sshd.common.util.ThreadUtils;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
import com.google.common.collect.Lists;
public class Server {
private SshServer sshServer = null;
private static final ARCFOUR128.Factory DEFAULT_ARCFOUR128_FACTORY = new ARCFOUR128.Factory();
private static final ARCFOUR256.Factory DEFAULT_ARCFOUR256_FACTORY = new ARCFOUR256.Factory();
private ScheduledExecutorService minaExecutor = null;
private ExecutorService nioExecutor = null;
public static final java.lang.String ALGORITHM = "RSA";
public static final int KEY_SIZE = 4096;
private IoServiceFactoryFactory nioServiceWithPoolFactoryFactory = null;
private ScheduledExecutorService minaTimerExecutor = null;
public static final int POOL_SIZE = 8;
private EventLoopGroup clientGroup = new NioEventLoopGroup();
public Server() {
constrctMinaExecutor();
constructNioExecutor();
nioServiceWithPoolFactoryFactory = new NetconfNio2ServiceFactory(
nioExecutor);
Properties properties = new Properties();
properties.setProperty("enc.sdn.callhome.address", "0.0.0.0");
setSshServerConfiguration(properties);
}
private void constructNioExecutor() {
nioExecutor = ThreadUtils.newFixedThreadPool(
"netconf-ssh-server-nio-group", POOL_SIZE);
}
private void constrctMinaExecutor() {
minaTimerExecutor = Executors.newScheduledThreadPool(POOL_SIZE,
new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
return new Thread(r, "Ssh_Netconf_Server_Timers");
}
});
}
public void setSshServerConfiguration(Properties serverConfig) {
sshServer = SshServer.setUpDefaultServer();
String serverIpAddress = serverConfig
.getProperty("enc.sdn.callhome.address");
String callHomeSshPort = serverConfig
.getProperty("enc.sdn.callhome.port");
int callHomePort = 8383;
try {
callHomePort = Integer.parseInt(callHomeSshPort);
} catch (Exception exception) {
exception.printStackTrace();
}
sshServer.setHost(serverIpAddress);
sshServer.setPort(callHomePort);
// remove rc4 ciphers
final List<NamedFactory<Cipher>> cipherFactories = sshServer
.getCipherFactories();
for (Iterator<NamedFactory<Cipher>> i = cipherFactories.iterator(); i
.hasNext();) {
final NamedFactory<Cipher> factory = i.next();
if (factory.getName()
.contains(DEFAULT_ARCFOUR128_FACTORY.getName())
|| factory.getName().contains(
DEFAULT_ARCFOUR256_FACTORY.getName())) {
i.remove();
}
}
sshServer.setPasswordAuthenticator(new CallHomeAuthenticator());
String keyPath = "/home/saravanakumar/distribution-karaf-0.3.1-Lithium-SR1/configuration/RSA.pk";
KeyPairProvider keyPairProvider = new PEMGeneratorHostKeyProvider(keyPath, ALGORITHM, KEY_SIZE);
sshServer.setKeyPairProvider(keyPairProvider);
sshServer.setIoServiceFactoryFactory(nioServiceWithPoolFactoryFactory);
sshServer.setScheduledExecutorService(minaTimerExecutor);
// sshServer.setProperties(getProperties(sshProxyServerConfiguration));
final NetconfCommandFactory netconfCommandFactory = new NetconfCommandFactory(
clientGroup);
System.out.println(" command factory :::");
sshServer.setSubsystemFactories(Lists
.<NamedFactory<Command>> newArrayList(netconfCommandFactory));
}
public void startServer() {
try {
sshServer.start();
} catch (IOException e) {
// TODO Auto-generated catch blockclear
e.printStackTrace();
}
}
public static void main(String a[]) {
Server server = new Server();
server.startServer();
}
}