{"id":13461811,"url":"https://github.com/jakeheis/Shout","last_synced_at":"2025-03-24T22:35:07.525Z","repository":{"id":39543271,"uuid":"91939164","full_name":"jakeheis/Shout","owner":"jakeheis","description":"SSH made easy in Swift","archived":false,"fork":false,"pushed_at":"2024-06-10T10:19:47.000Z","size":102,"stargazers_count":365,"open_issues_count":18,"forks_count":105,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-03T03:46:02.748Z","etag":null,"topics":["libssh2","ssh","swift-server"],"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/jakeheis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-21T07:04:18.000Z","updated_at":"2025-02-28T05:02:19.000Z","dependencies_parsed_at":"2024-01-16T22:17:45.171Z","dependency_job_id":"495c9707-2001-42fc-ae84-eb490541942e","html_url":"https://github.com/jakeheis/Shout","commit_stats":{"total_commits":90,"total_committers":14,"mean_commits":6.428571428571429,"dds":"0.30000000000000004","last_synced_commit":"9612c13375599cfecf892d49e2d53d0143c04bc1"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakeheis%2FShout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakeheis%2FShout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakeheis%2FShout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakeheis%2FShout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakeheis","download_url":"https://codeload.github.com/jakeheis/Shout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245366204,"owners_count":20603438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["libssh2","ssh","swift-server"],"created_at":"2024-07-31T11:00:58.264Z","updated_at":"2025-03-24T22:35:02.507Z","avatar_url":"https://github.com/jakeheis.png","language":"Swift","readme":"# Shout\n\n[![Build Status](https://github.com/jakeheis/Shout/workflows/Test/badge.svg)](https://github.com/jakeheis/Shout/actions)\n\nSSH made easy in Swift\n\n```swift\nimport Shout\n\nlet ssh = try SSH(host: \"example.com\")\ntry ssh.authenticate(username: \"user\", privateKey: \"~/.ssh/id_rsa\")\ntry ssh.execute(\"ls -a\")\ntry ssh.execute(\"pwd\")\n...\n```\n\n## Installation\n### [Ice Package Manager](https://github.com/jakeheis/Ice)\n```shell\n\u003e ice add jakeheis/Shout\n```\n### Swift Package Manager\nAdd Shout as a dependency to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/jakeheis/Shout\", from: \"0.5.5\")\n]\n```\n\n## Swift 5.2 note\n\nDue to a bug in Swift 5.2, in order to build a project that depends on `Shout` you must explicitly tell SPM where to find the pkgconfig for `libssh2`. If you installed `libssh2` using Homebrew, the instruction looks something like:\n\n```bash\nexport PKG_CONFIG_PATH=\"/usr/local/opt/openssl@1.1/lib/pkgconfig\"\nswift build\n```\n\nGenerating an Xcode project is done the same way:\n\n```bash\nexport PKG_CONFIG_PATH=\"/usr/local/opt/openssl@1.1/lib/pkgconfig\"\nswift package generate-xcodeproj\n```\n\nSee [issue #34](https://github.com/jakeheis/Shout/issues/34) for more details.\n\n## Usage\n\n### Creating a session\nYou create a session by passing a host and optionally a port (default 22):\n```swift\nlet ssh = try SSH(host: \"example.com\")\n// or\nlet ssh = try SSH(host: \"example.com\", port: 22)\n```\n\n### Authenticating\n\nYou can authenticate with a private key, a password, or an agent.\n\n#### Private key\n\nTo authenticate with a private key, you must pass the username and the path to the private key. You can also pass the path to the public key (defaults to the private key path + \".pub\") and the passphrase encrypting the key (defaults to nil for no passphrase)\n\n```swift\nsession.authenticate(username: \"user\", privateKey: \"~/.ssh/id_rsa\")\n// or\nsession.authenticate(username: \"user\", privateKey: \"~/.ssh/id_rsa\", publicKey: \"~/.ssh/id_rsa.pub\", passphrase: \"passphrase\")\n```\n\n#### Password\nSimply pass the username and password:\n```swift\nsession.authenticate(username: \"user\", password: \"password\")\n```\n\n#### Agent\nIf you've already added the necessary private key to ssh-agent, you can authenticate using the agent:\n```swift\nsession.authenticateByAgent(username: \"user\")\n```\n\n### Executing commands\n\nYou can remotely execute a command one of two ways. `session.execute` will print the output of the command to stdout and return the status of the command, while `session.capture` will not print anything to stdout and will return both the status and the output of the command as a string.\n```swift\nlet status = try session.execute(\"ls -a\")\nlet (status, output) = try session.capture(\"pwd\")\n```\n\n### Send files\n\nYou can send a local file to a remote path, similar to the `scp` command line program, with `sendFile`.\n```swift\nlet status = try session.sendFile(localURL: myLocalFile, remotePath: \"~/cats.png\")\n```\n\n### SFTP\n\nYou can open an SFTP session with the remote server:\n\n```swift\nlet sftp = try session.openSftp()\ntry sftp.download(remotePath: \"/a/remote/file\", localURL: myLocalFile)\ntry sftp.upload(localURL: myLocalFile, remotePath: \"~/cats.png\")\n```\n\n### Configuration\n\nYou can instruct the session to request a pty (pseudo terminal) before executing commands:\n```swift\nsession.ptyType = .vanilla\n```\n","funding_links":[],"categories":["Swift","HarmonyOS"],"sub_categories":["Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakeheis%2FShout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakeheis%2FShout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakeheis%2FShout/lists"}