What's New
- Multi-key public-key authentication - Pass several private keys in a
PrivateKeySetand let SwiftSFTP pick among them. Keys are classified by algorithm, filtered and ordered using the server’s RFC 8308server-sig-algswhen available, then tried until one succeeds—similar in spirit to OpenSSH multi-IdentityFile, without scanning~/.sshor 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"))