Objective-C

SSHKit ships a parallel Objective-C façade (SSHKitObjC) covering connection, command, shell, SFTP, tunneling, and forwarding. A few Swift-only conveniences — the SCP helpers, the keychain credential store, key generation wrappers, the algorithm-profile struct, and the latency probe — do not have direct Obj-C counterparts and are listed at the bottom of this page. Import the umbrella header:

#import <SSHKitObjC/SSHKitObjC.h>

Canonical example

SSHKitConfiguration *configuration =
    [[SSHKitConfiguration alloc] initWithHost:@"example.com"
                                     username:@"deploy"];

configuration.authentication = [SSHKitAuthentication password:@"secret"];
// Use a known_hosts file on first connection; switch to a populated
// keychain trust store after you have stored the server's fingerprint.
configuration.hostKeyPolicy =
    [SSHKitHostKeyPolicy knownHostsFile:[@"~/.ssh/known_hosts" stringByExpandingTildeInPath]];

[SSHKitClient connectWithConfiguration:configuration
                            completion:^(SSHKitConnection *connection, NSError *error) {
    if (error != nil) {
        NSLog(@"connect failed: %@", error);
        return;
    }
    [connection executeCommand:@"uname -a"
                    completion:^(SSHKitCommandResult *result, NSError *error) {
        if (error != nil) {
            NSLog(@"execute failed: %@", error);
            return;
        }
        NSString *stdout = [[NSString alloc] initWithData:result.standardOutput
                                                 encoding:NSUTF8StringEncoding];
        NSLog(@"%@ (exit %d)", stdout, result.exitStatus);
        [connection disconnectWithCompletion:^(NSError *error) {}];
    }];
}];

Class & type inventory

Entry & configuration

TypeHeaderPurpose
SSHKitClientSSHKitClient.hConnect + auth-method discovery class methods.
SSHKitConfigurationSSHKitConfiguration.hConnection settings (auth, host trust, proxy, algorithms, logging).
SSHKitAuthenticationSSHKitConfiguration.hAuth method wrapper with +password:, +privateKeyFileAtPath:passphrase:, +keyboardInteractiveWithResponder:, +agent, +agentWithSocketPath:.
SSHKitAuthenticationKindSSHKitConfiguration.hNS_ENUM: password / privateKeyFile / keyboardInteractive / agent.
SSHKitKeyboardInteractivePromptSSHKitConfiguration.hPrompt passed to the keyboard-interactive responder.
SSHKitProxyRouteKindSSHKitConfiguration.hNS_ENUM: none / SOCKS5 / HTTPConnect / ProxyJump.

Host trust

TypeHeaderPurpose
SSHKitHostKeyPolicySSHKitConfiguration.hWrapper with +knownHostsFile:, +pinnedFingerprint:, +trustStore:, +keychainTrustStoreWithService:, +memoryTrustStore, +insecureAcceptAnyHostKey.
SSHKitHostKeyPolicyKindSSHKitConfiguration.hNS_ENUM: insecure / knownHostsFile / pinned / trusted.
SSHKitHostTrustStoreSSHKitConfiguration.hAbstract base — fingerprintForHost:port:error:, saveFingerprint:host:port:error:, removeFingerprintForHost:port:error:.
SSHKitMemoryTrustStoreSSHKitConfiguration.hIn-memory subclass.
SSHKitKeychainTrustStoreSSHKitConfiguration.hKeychain-backed subclass; +defaultService = wiki.qaq.sshkit.

Connection & jobs

TypeHeaderPurpose
SSHKitConnectionSSHKitConnection.hConnect, execute (with optional PTY via executePTYCommand:completion:), open command/shell/SFTP/tunnel/forward, disconnect.
SSHKitCommandResultSSHKitConnection.hCollected command output + exit status + optional exit signal.
SSHKitCommandSSHKitConnection.hStreamed command channel (writeData:, sendEOF, close).
SSHKitCommandEvent / SSHKitCommandEventKindSSHKitConnection.hEvent delivered to the streamed-command handler.
SSHKitShellSSHKitConnection.hPTY shell channel (writeData:, resizeWithColumns:rows:, close).
SSHKitShellEvent / SSHKitShellEventKindSSHKitConnection.hEvent delivered to the shell handler.
SSHKitTunnelChannelSSHKitConnection.hDirect TCP channel I/O.
SSHKitPortForwardSSHKitConnection.hLocal / remote / dynamic forward handle (boundHost, boundPort).

SFTP

TypeHeaderPurpose
SSHKitSFTPClientSSHKitConnection.hFull SFTP surface: list, stat, mkdir, rmdir, rename, symlink, open, read, write, upload, download, resumable transfers with progress.
SSHKitSFTPFileHandleSSHKitConnection.hStreaming file handle (readDataWithMaximumLength:, writeData:, seekToOffset:, close).
SSHKitSFTPEntrySSHKitConnection.hDirectory entry (filename, attributes).
SSHKitSFTPAttributesSSHKitConnection.hFile attributes (size, permissions, uid, gid, type, dates).
SSHKitSFTPFileOpenFlagsSSHKitConnection.hNS_OPTIONS: Read / Write / Create / Truncate / Append.

Authentication discovery

TypeHeaderPurpose
SSHKitAuthenticationDiscoveryResultSSHKitConnection.hReturned by discoverAuthenticationMethodsWithCompletion:: methods + banners.
SSHKitAuthenticationMethodSSHKitConnection.hNS_ENUM: none / password / publicKey / hostBased / keyboardInteractive / gssapi.

Host-key discovery

SymbolHeaderPurpose
SSHKitHostKeyDiscoveryResultSSHKitConnection.hNSObject with host (NSString), port (uint16_t), and fingerprint (NSString in SHA256:… form).
SSHKitHostKeyDiscoveryCompletionSSHKitConnection.hBlock typedef: void(^)(SSHKitHostKeyDiscoveryResult *_Nullable, NSError *_Nullable).
+[SSHKitClient discoverHostKeyWithConfiguration:completion:]SSHKitClient.hStateless entry point. Builds a discovery-only session from an SSHKitConfiguration, returns the result, and tears the session down.
-[SSHKitConnection discoverHostKeyWithCompletion:]SSHKitConnection.hInstance variant for callers that have already constructed an SSHKitConnection from a discovery configuration.

Either entry point performs a transport-only handshake. Build an SSHKitConfiguration with the host, port, timeout, proxy, and algorithm fields — authentication and username are not consulted during discovery.

Logging

TypeHeaderPurpose
SSHKitLogLevelSSHKitConfiguration.hNS_ENUM: debug / info / warning / error.
SSHKitLogEventSSHKitConfiguration.hLevel + phase + message + metadata + timestamp.
SSHKitLogRecorderSSHKitConfiguration.hBounded log buffer; events stored in their redacted form.
SSHKitLogHandlerSSHKitConfiguration.hBlock typedef: void(^)(SSHKitLogEvent *).

Errors

SymbolHeaderPurpose
SSHKitErrorDomainSSHKitError.hNSErrorDomain used by every emitted NSError.
SSHKitErrorCodeSSHKitError.hNS_ERROR_ENUM with codes 1–11 (see the code table).
SSHKitMakeError(code, message)SSHKitError.hHelper to build an NSError in the SSHKit domain.

Key generation & algorithm inspection

TypeHeaderPurpose
SSHKitGeneratedKeyPairSSHKitGeneratedKeyPair.h+generateOpenSSHKeyPairWithType:bits:comment:passphrase:error:.
SSHKitKeyGenerationTypeSSHKitGeneratedKeyPair.hNS_ENUM: Ed25519 / RSA / ECDSAP256 / ECDSAP384 / ECDSAP521.
SSHKitAlgorithmInspectorSSHKitAlgorithmInspector.h+inspectAlgorithmsWith… — resolves a profile against the vendored libssh build.

Swift → Obj-C mapping

SwiftObjective-C
SSHClientSSHKitClient
SSHClient.Configuration / SSHClientConfigurationSSHKitConfiguration
SSHAuthenticationSSHKitAuthentication + SSHKitAuthenticationKind
SSHKeyboardInteractivePromptSSHKitKeyboardInteractivePrompt
SSHHostKeyPolicySSHKitHostKeyPolicy + SSHKitHostKeyPolicyKind
SSHHostTrustStoreSSHKitHostTrustStore (abstract base class)
SSHMemoryHostTrustStoreSSHKitMemoryTrustStore
SSHKeychainHostTrustStoreSSHKitKeychainTrustStore
SSHProxyRouteSSHKitProxyRouteKind + proxy fields on SSHKitConfiguration
SSHConnectionSSHKitConnection
SSHCommandResultSSHKitCommandResult
SSHCommand / SSHCommandEventSSHKitCommand / SSHKitCommandEvent
SSHShell / SSHShellEventSSHKitShell / SSHKitShellEvent
SFTPClientSSHKitSFTPClient
SFTPFileHandleSSHKitSFTPFileHandle
SFTPEntry / SFTPAttributes / SFTPFileOpenFlagsSSHKitSFTPEntry / SSHKitSFTPAttributes / SSHKitSFTPFileOpenFlags
SSHTunnelChannelSSHKitTunnelChannel
SSHPortForwardSSHKitPortForward
SSHAuthenticationMethod / SSHAuthenticationDiscoveryResultSSHKitAuthenticationMethod / SSHKitAuthenticationDiscoveryResult
SSHHostKeyDiscoveryConfiguration / SSHDiscoveredHostKey / SSHClient.discoverHostKeySSHKitConfiguration (transport fields) / SSHKitHostKeyDiscoveryResult / +[SSHKitClient discoverHostKeyWithConfiguration:completion:] (or -[SSHKitConnection discoverHostKeyWithCompletion:])
SSHLogLevel / SSHLogEvent / SSHLogRecorderSSHKitLogLevel / SSHKitLogEvent / SSHKitLogRecorder
SSHKitError / SSHKitErrorCodeNSError in SSHKitErrorDomain / SSHKitErrorCode
SSHGeneratedKeyPair / SSHKeyGenerator / SSHKeyGenerationTypeSSHKitGeneratedKeyPair / SSHKitKeyGenerationType
SSHAlgorithmProfile (inspection)SSHKitAlgorithmInspector

Obj-C-only surface

One method has no direct Swift counterpart:

Swift-only surface

These are Swift conveniences with no direct Obj-C counterpart: