sshj Java Library

repository·master·Indexed 25 days ago

https://github.com/hierynomus/sshj

A comprehensive SSHv2 library for Java that supports authentication (publickey, password, keyboard-interactive), channel management (command, subsystem, shell), port forwarding, and file transfers via SCP and SFTP. It includes FIDO/U2F support via SecurityKeySigner and SSH Agent authentication.

Tokens
524
Snippets
2
Records
5
Agent score
33%

What's inside sshj

  1. SSHJ Core Features

    master

    SSHJ provides a comprehensive set of SSHv2 capabilities, including:

    • Host Verification: Reading known_hosts files.
    • Authentication: Support for publickey, password, and keyboard-interactive methods.
    • Security Keys: FIDO/U2F support via SecurityKeySigner (e.g., sk-ecdsa-sha2-nistp256@openssh.com).
    • SSH Agent: Authentication over SSH_AUTH_SOCK (requires Java 16+ for built-in unix-domain socket transport).
    • Channels: Support for command, subsystem, and shell channels.
    • Port Forwarding: Both local and remote port forwarding.
    • File Transfer: Implementation of scp and a complete sftp version 0-3.
  2. Install SSHJ via Maven

    master

    To use SSHJ in your Java project, add the following dependency to your pom.xml. Ensure you are using version 0.38.0 or higher to avoid vulnerabilities related to CVE-2023-48795 (Terrapin).

    <dependency>
      <groupId>com.hierynomus</groupId>
      <artifactId>sshj</artifactId>
      <version>0.40.0</version>
    </dependency>
  3. Run SSHJ examples

    master

    The examples directory contains a Maven project demonstrating various use cases. To run them:

    1. Install Maven 2.2.1 or higher.
    2. Clone the SSHJ repository.
    3. Navigate to the examples directory.
    4. Run mvn eclipse:eclipse to generate Eclipse project files.
    5. Import the project into Eclipse.
    6. Update the login details (address, username, and password) in the example classes before running.