mina-sshd icon indicating copy to clipboard operation
mina-sshd copied to clipboard

HostConfigEntry resolveIdentityFilePath Identity Problem

Open fragaLY opened this issue 1 year ago • 6 comments

Version

2.14.0

Bug description

During the client#connect invocation, I am facing the parsing problem that provides me with identity in format "~/.ssh/sftp.pem", but Tilda is expected to be the first token.

public class Main {

    private static final int DEFAULT_SFTP_SESSION_TIMEOUT = 1500;

    public static void main(String[] args) throws IOException {
        SshClient client = null;
        ClientSession session = null;
        try {
            client = SshClient.setUpDefaultClient();
            client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE);
            client.start();
            session = client.connect("user, "host", port).verify(DEFAULT_SFTP_SESSION_TIMEOUT, TimeUnit.MILLISECONDS).getSession();
            session.addPasswordIdentity("password");
            session.auth().verify(DEFAULT_SFTP_SESSION_TIMEOUT, TimeUnit.MILLISECONDS);
            System.out.println(session);
        } catch (Exception e) {
            var message = "Failed to create SSHClient Session:" + e.getMessage();
            System.out.println(message);
        } finally {
            Objects.requireNonNull(session).close();
            Objects.requireNonNull(client).close();
        }
    }
}

Actual behavior

Home tilde must be first: "~/.ssh/sftp.pem"

Expected behavior

Connection established.

Relevant log output

No response

Other information

No response

fragaLY avatar Oct 11 '24 08:10 fragaLY