Utilities

The symbols documented on this page are intended to be safe. They may throw exceptions but they should never cause memory corruptions or segfaults if used correctly.

This documents the various other parts of the libssh API that aren't strictly connected to client or server support.


LibSSH.get_hexaFunction
get_hexa(buffer::Vector{UInt8}) -> String

Convert a buffer to a colon-separated hex string. This is identical to bytes2hex(), except that each byte will be separated by a colon.

Wrapper around lib.ssh_get_hexa().

Examples

julia> import LibSSH as ssh

julia> buffer = collect(UInt8, 1:10);

julia> ssh.get_hexa(buffer)
"01:02:03:04:05:06:07:08:09:0a"

julia> bytes2hex(buffer)
"0102030405060708090a"
source

GSSAPI support

LibSSH.Gssapi.isavailableFunction
isavailable() -> Bool

Check if GSSAPI support is available. Currently this is only available on Linux and FreeBSD because it's difficult to cross-compile Kerberos_krb5_jll for other platforms (which is what we depend on for GSSAPI).

source

Messages

LibSSH.message_auth_interactive_requestFunction
message_auth_interactive_request(
    msg::Ptr{LibSSH.lib.ssh_message_struct},
    name::AbstractString,
    instruction::AbstractString,
    prompts::Vector{String},
    echo::Vector{Bool}
) -> Int32

This is useful when writing a server, it will specify the requirements for keyboard-interactive authentication to the client.

Parameters

  • msg: The message to reply to.
  • name: The name of the message block.
  • instruction: The instruction for the user.
  • prompts: The prompts to show to the user.
  • echo: Whether the client should echo the answer to the prompts (e.g. it probably shouldn't echo the password).

Wrapper around lib.ssh_message_auth_interactive_request().

source

PKI

LibSSH.PKI.HashTypeType
primitive type HashType <: Enum{Int32} 32

Enum for possible hash types to use to hash a public key:

  • HashType_Sha1
  • HashType_Md5
  • HashType_Sha256
source
LibSSH.PKI.KeyCmpType
primitive type KeyCmp <: Enum{Int32} 32

Enum for ways to compare keys:

  • KeyCmp_Public
  • KeyCmp_Private
source
LibSSH.PKI.KeyTypeType
primitive type KeyType <: Enum{Int32} 32

Enum for the types of keys that are supported:

  • KeyType_unknown
  • KeyType_dss
  • KeyType_rsa
  • KeyType_rsa1
  • KeyType_ecdsa
  • KeyType_ed25519
  • KeyType_dss_cert01
  • KeyType_rsa_cert01
  • KeyType_ecdsa_p256
  • KeyType_ecdsa_p384
  • KeyType_ecdsa_p521
  • KeyType_ecdsa_p256_cert01
  • KeyType_ecdsa_p384_cert01
  • KeyType_ecdsa_p521_cert01
  • KeyType_ed25519_cert01
  • KeyType_sk_ecdsa
  • KeyType_sk_ecdsa_cert01
  • KeyType_sk_ed25519
  • KeyType_sk_ed25519_cert01
source
LibSSH.PKI.SshKeyType
mutable struct SshKey
  • ptr::Union{Nothing, Ptr{LibSSH.lib.ssh_key_struct}}

  • owning::Bool

Use PKI.generate to create a key rather than calling the constructors. A SshKey can be owning or non-owning of its pointer to the lib.ssh_key.

Warning

Adding a SshKey to a ssh.Bind will cause the key to be free'd when the ssh.Bind is closed! Never use a SshKey after its server has been closed, or make sure it hasn't been free'd by checking isassigned(::SshKey).

source
LibSSH.PKI.get_fingerprint_hashMethod
get_fingerprint_hash(hash_buffer::Vector{UInt8}) -> String

Get a fingerprint of a public key from a hash. This will automatically guess the kind of hash that was used from the length of hash_buffer.

Wrapper around lib.ssh_get_fingerprint_hash().

Examples

julia> import LibSSH.PKI as pki
julia> key = pki.generate(pki.KeyType_ed25519)
julia> sha256_hash = pki.get_publickey_hash(key)
julia> pki.get_fingerprint_hash(sha256_hash)
"SHA256:5muLWD4Cl6FYh5ZRr/DYKvmb5r+kJUZQXLuc6ocVRH0"
source