{"id":28415545,"url":"https://github.com/gaetanzanella/swift-ssh-client","last_synced_at":"2026-04-27T08:31:25.392Z","repository":{"id":63519276,"uuid":"568129608","full_name":"gaetanzanella/swift-ssh-client","owner":"gaetanzanella","description":"High-level SSH client interfaces using SwiftNIO SSH","archived":false,"fork":false,"pushed_at":"2023-10-16T20:00:48.000Z","size":156,"stargazers_count":24,"open_issues_count":4,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-25T15:51:36.572Z","etag":null,"topics":["ios","macos","sftp-client","ssh","swift-nio"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaetanzanella.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-19T14:46:05.000Z","updated_at":"2025-03-27T01:20:13.000Z","dependencies_parsed_at":"2023-01-23T19:01:14.885Z","dependency_job_id":null,"html_url":"https://github.com/gaetanzanella/swift-ssh-client","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/gaetanzanella/swift-ssh-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaetanzanella%2Fswift-ssh-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaetanzanella%2Fswift-ssh-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaetanzanella%2Fswift-ssh-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaetanzanella%2Fswift-ssh-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaetanzanella","download_url":"https://codeload.github.com/gaetanzanella/swift-ssh-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaetanzanella%2Fswift-ssh-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32329462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","macos","sftp-client","ssh","swift-nio"],"created_at":"2025-06-03T17:00:24.735Z","updated_at":"2026-04-27T08:31:25.358Z","avatar_url":"https://github.com/gaetanzanella.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift SSH Client\n\nThis project provides high-level SSH client interfaces using [SwiftNIO SSH](https://github.com/apple/swift-nio-ssh).\n\n## Requirements\n\n`Swift SSH Client` is compatible with iOS 13.0+ and macOS 10.5+.\n\n## Getting started\n\nSSH is a multiplexed protocol: each SSH connection is subdivided into multiple bidirectional communication channels.    \n\n`Swift SSH Client` reflects this pattern. The first step is to set a connection up:\n\n```swift\nlet connection = SSHConnection(\n    host: \"my_host\",\n    port: my_port,\n    authentication: SSHAuthentication(\n        username: \"my_username\",\n        method: .password(.init(\"my_password\")),\n        hostKeyValidation: .acceptAll()\n    )\n)\n\ntry await connection.start()\n```\n \nOnce connected, you can start executing concrete SSH operations on child communication channels.\nAs `SSH Client` means to be a high level interface, you do not directly interact with them.\nInstead you use interfaces dedicated to your use case.\n\n- SSH commands\n```swift\nlet response = try await connection.execute(\"echo Hello\\n\")\n// Handle response\n\nfor try await chunk in connection.stream(\"echo World\\n\") {\n    // Handle chunk\n}\n```\n\n- SSH shell\n```swift\nlet shell = try await connection.requestShell()\nfor try await chunk in shell.data {\n    // Handle chunk\n}\n```\n\n- SFTP client\n```swift\nlet sftpClient = try await connection.requestSFTPClient()\n\n// directories\ntry await sftpClient.createDirectory(at: \"./new\")\ntry await sftpClient.removeDirectory(at: \"./new\")\n\n// files\nlet file = try await client.openFile(at: \"./new/file.txt\", flags: .create)\ntry await file.write(\"Hello World!\".data(using: .utf8)!)\ntry await file.close()\n\n// and more\n``` \n\nYou keep track of the connection state, using the dedicated `stateUpdateHandler` property:\n```swift\nconnection.stateUpdateHandle = { state in\n    switch state {\n    case .idle, .failed:\n        // Handle disconnection\n    case .ready:\n        // Handle connection start\n    }\n}\n```\n\nAs `SSHConnection` represents the overall SSH connection, if it ends, all the SSH operations or clients linked to it will end accordingly.\n\n## Beta version\n\nConsider the `0.1` version as a beta version. From patch to patch, the project API can change a lot. \n\n## License\n\n`Swift SSH Client` is available under the MIT license. See the `LICENSE.txt` file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaetanzanella%2Fswift-ssh-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaetanzanella%2Fswift-ssh-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaetanzanella%2Fswift-ssh-client/lists"}