Skip to content

It gives Auth fail when try to connect via jsch #10

@chanurahemal

Description

@chanurahemal

My code is as bellow. The server is creating properly and i can put files as well. But when i try to connect to server using jsch, it always gives "Auth fail" in session.connect()

    withSftpServer(server -> {
        server.addUser("username", "password1").setPort(1234);

        JSch jsch = new JSch();
        Session session = null;
        Channel channel = null;
        ChannelSftp channelSftp = null;
        final int rPort = Integer.parseInt("22");
        String knownHostPublicKey = "127.0.0.1" + " ssh-rsa " + <<HOST-KEY>>;
        jsch.setKnownHosts(new ByteArrayInputStream(knownHostPublicKey.getBytes()));
        session = jsch.getSession("username", "127.0.0.1", rPort);
        session.setPassword("password1");
        session.setTimeout(25000);
        session.connect(25000); **//Auth fail here**
        channel = session.openChannel("sftp");
        channel.connect();
        channelSftp = (ChannelSftp) channel;

    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions