コード例 #1
0
ファイル: SSHServer.java プロジェクト: otonielsilva/tomee
  @Override
  public void start() throws ServiceException {
    sshServer = SshServer.setUpDefaultServer();
    sshServer.setPort(port);
    sshServer.setHost(bind);

    final String basePath = SystemInstance.get().getBase().getDirectory().getAbsolutePath();
    if (SecurityUtils.isBouncyCastleRegistered()) {
      sshServer.setKeyPairProvider(
          new PEMGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".pem").getPath()));
    } else {
      sshServer.setKeyPairProvider(
          new SimpleGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".ser").getPath()));
    }

    final OpenEJBShellFactory sf = new OpenEJBShellFactory(bind, port);
    sshServer.setShellFactory(sf);

    final JaasPasswordAuthenticator authenticator = new OpenEJBJaasPasswordAuthenticator();
    authenticator.setDomain(domain);
    sshServer.setPasswordAuthenticator(authenticator);

    try {
      sshServer.start();
    } catch (IOException e) {
      // no-op
    }
  }
コード例 #2
0
ファイル: NccCLI.java プロジェクト: seko99/NCC
 public void start() {
   logger.info("Starting CLI on port " + Ncc.cliSshPort);
   try {
     sshd.start();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #3
0
ファイル: Server.java プロジェクト: ardumont/magrit
 @Override
 public void start() throws ServiceException {
   sshd.setPort(port);
   try {
     sshd.start();
   } catch (IOException e) {
     throw new ServiceException(e);
   }
 }
コード例 #4
0
ファイル: OpalSshServer.java プロジェクト: emorency/opal
 @Override
 public void start() {
   try {
     log.info("Starting Opal SSH Server on port {}", sshd.getPort());
     sshd.start();
     isRunning = true;
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
コード例 #5
0
 /**
  * Starts a ssh server on the provided port.
  *
  * @param server the server mock to start
  * @return the server.
  * @throws IOException if so.
  */
 public static SshServer startServer(SshdServerMock server) throws IOException {
   SshServer sshd = SshServer.setUpDefaultServer();
   sshd.setPort(0);
   sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
   List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
   userAuthFactories.add(new UserAuthNone.Factory());
   sshd.setUserAuthFactories(userAuthFactories);
   sshd.setCommandFactory(server);
   sshd.start();
   return sshd;
 }
コード例 #6
0
ファイル: SCPTest.java プロジェクト: akazaSST/testcases
  @Before
  public void setup() throws Exception {
    int port = AvailablePortFinder.getNextAvailable(10000);

    // Write port number to configuration file in target
    String basedir = System.getProperty("basedir");
    if (basedir == null) {
      basedir = new File(".").getCanonicalPath();
    }

    // Read in camel configuration file and substitute in the correct port
    File f = new File(basedir + "/src/test/resources/camel-scp.xml");

    FileInputStream inputStream = new FileInputStream(f);
    String content = IOUtils.toString(inputStream, "UTF-8");
    inputStream.close();
    content = content.replaceAll("portno", "" + port);

    File f2 = new File(basedir + "/target/test-classes/camel-scp.xml");
    FileOutputStream outputStream = new FileOutputStream(f2);
    IOUtils.write(content, outputStream, "UTF-8");
    outputStream.close();

    sshServer = SshServer.setUpDefaultServer();
    sshServer.setPort(port);

    // Generate a key
    sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("target/generatedkey.pem"));

    sshServer.setCommandFactory(new ScpCommandFactory());

    sshServer.setPasswordAuthenticator(new CamelPasswordAuthenticator());
    sshServer.start();

    setupKnownHosts(port);

    // Create "storage" directory (delete it first if it exists)
    File storageDirectory = new File(basedir + "/target/storage");
    if (storageDirectory.exists()) {
      storageDirectory.delete();
    }
    storageDirectory.mkdir();
  }
コード例 #7
0
  public void start() throws IOException {
    if (isRunning()) {
      return;
    }

    sshd = SshServer.setUpDefaultServer();

    sshd.setPort(RGSParametersCLI.getSSHDServerPort());
    sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(HOST_KEY_PROVIDER_FILE));
    sshd.setFileSystemFactory(
        new CodeOrchestraFileSystemFactory(RGSParametersCLI.getWorkspacePath()));

    // sshd.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh", "-i", "-l" }));

    List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
    userAuthFactories.add(new UserAuthPassword.Factory());
    sshd.setUserAuthFactories(userAuthFactories);
    sshd.setPasswordAuthenticator(
        new PasswordAuthenticator() {
          @Override
          public boolean authenticate(String user, String password, ServerSession serverSession) {
            return user.equals(RGSParametersCLI.getUsername())
                && password.equals(RGSParametersCLI.getPassword());
          }
        });

    sshd.setCommandFactory(new ScpCommandFactory());

    List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>();
    namedFactoryList.add(new SftpSubsystem.Factory());
    sshd.setSubsystemFactories(namedFactoryList);

    sshd.start();

    running = true;
  }