Skip to content

Version 3.10.0

Latest

Choose a tag to compare

@RuiNelson RuiNelson released this 08 Aug 00:58
· 1 commit to main since this release

What's New

  • Multi-key public-key authentication - Pass several private keys in a PrivateKeySet and let SwiftSFTP pick among them. Keys are classified by algorithm, filtered and ordered using the server’s RFC 8308 server-sig-algs when available, then tried until one succeeds—similar in spirit to OpenSSH multi-IdentityFile, without scanning ~/.ssh or using ssh-agent.
let client = try await SFTPClient.initAndLogin(
    openSocketIn: TCPLocation(hostname: "sftp.example.com"),
    authentication: UserAuthentication(
        name: "alice",
        auth: .privateKeys(.init(files: [
            .init(file: URL(filePath: "/Users/alice/.ssh/id_ed25519")),
            .init(file: URL(filePath: "/Users/alice/.ssh/id_rsa")),
            .init(
                file: URL(filePath: "/Users/alice/.ssh/id_ecdsa"),
                passphrase: "optional"
            ),
        ]))
    )
)

Single-key logins use the same path: .privateKeys(.init(url)) or .privateKeys(.init(pemText, passphrase: nil)). Formats: PEM, PKCS#8, OpenSSH. Algorithms: RSA, ECDSA P-256/384/521, Ed25519. See the User’s Guide — Authentication.

Migration Guide

.privateKeyFile(file:password:) and .privateKeyString(keyData:password:) are deprecated. Prefer .privateKeys:

Before:

auth: .privateKeyFile(file: url, password: nil)
auth: .privateKeyString(keyData: pem, password: "x")

After:

auth: .privateKeys(.init(url))
auth: .privateKeys(.init(pem, passphrase: "x"))