Package com.jcraft.jsch

Examples of com.jcraft.jsch.JSch


     * @throws Exception If a problem occurs.
     */
    private String key() throws Exception {
        final ByteArrayOutputStream stream = new ByteArrayOutputStream();
        try {
            final KeyPair kpair = KeyPair.genKeyPair(new JSch(), KeyPair.DSA);
            kpair.writePublicKey(stream, "");
            kpair.dispose();
        } finally {
            stream.close();
        }
View Full Code Here


    final File identityFile = hc.getIdentityFile();
    if (identityFile == null)
      return defaultJSch;

    final String identityKey = identityFile.getAbsolutePath();
    JSch jsch = byIdentityFile.get(identityKey);
    if (jsch == null) {
      jsch = new JSch();
      jsch.setHostKeyRepository(defaultJSch.getHostKeyRepository());
      jsch.addIdentity(identityKey);
      byIdentityFile.put(identityKey, jsch);
    }
    return jsch;
  }
View Full Code Here

   * @return the new default JSch implementation.
   * @throws JSchException
   *             known host keys cannot be loaded.
   */
  protected JSch createDefaultJSch(FS fs) throws JSchException {
    final JSch jsch = new JSch();
    knownHosts(jsch, fs);
    identities(jsch, fs);
    return jsch;
  }
View Full Code Here

    public static void main(String[] args) {
        NullCipher nullCipher = new NullCipher();
        System.out.println(nullCipher);

        JSch jsch = new JSch();
        System.out.println(jsch);
    }
View Full Code Here

    private String passwd;
    private String serv;
    private String login;
   
    public ConnexionEDI(String login, String serv, int port) throws JSchException{
  this.id = new JSch();
  this.login = login;
  this.serv = serv;
  this.session = id.getSession(this.login, this.serv, 22);
  this.passwd = "edi";
    }
View Full Code Here

  public Ssh(Resource resource, String basePath) throws Exception
  {
    super(resource, basePath);

    JSch jsch = new JSch();

    Properties config = new Properties();
    config.put("StrictHostKeyChecking", "no");

    session = jsch.getSession(resource.getString("user"), resource.getString("host"), Integer.parseInt(resource.getString("port")));
    session.setConfig(config);
    session.setPassword(resource.getString("pw"));
    session.connect();

    channel = (ChannelSftp) session.openChannel("sftp");
View Full Code Here

     */
    public void connect() throws SshException {
        exceptIfAlreadyConnected();

        try {
            JSch jsch = new JSch();

            validateMembers();

            if (this.usePrivateKey) {
                jsch.addIdentity(this.privateKeyFile.getAbsolutePath());
            }

            this.sshSession = jsch.getSession(this.username, this.host, this.port);
            this.sshSession.setConfig(SSH_PROPERTIES);

            if (!this.usePrivateKey && this.password != null) {
                this.sshSession.setPassword(this.password);
            }
View Full Code Here

  
    private boolean login()
    {
        try
        {
            JSch jsch = new JSch();
            if(keyfile != null) {
              jsch.addIdentity(keyfile);
            }
            session = jsch.getSession(user, host, this.port);
            UserInfo ui = new MyUserInfo(pass);
            session.setUserInfo(ui);
            session.connect();
           
View Full Code Here

        return sb.toString();
    }

  public SSHKeysHelper() {
    try {
       keyPair = KeyPair.genKeyPair(new JSch(), KeyPair.RSA);
    } catch (JSchException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

        return this.accessInfo;
    }

    public void connect() {
        try {
            JSch jsch = new JSch();

            if (sshConfiguration.getKnownHostsFile() != null) {
                jsch.setKnownHosts(sshConfiguration.getKnownHostsFile());
            }

            //if (accessInfo.getKey() != null) {
            //    jsch.addIdentity(...);
            //}

            Credentials credentials = getCredentialsToUse();

            session = jsch.getSession(credentials.getUsername(), accessInfo.getHost(), accessInfo.getPort());

            if (credentials.getPassword() != null) {
                session.setPassword(credentials.getPassword());
            }
View Full Code Here

TOP

Related Classes of com.jcraft.jsch.JSch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.