{"id":13519306,"url":"https://github.com/dazzle-php/ssh","last_synced_at":"2025-08-12T22:37:42.098Z","repository":{"id":217981479,"uuid":"95324089","full_name":"dazzle-php/ssh","owner":"dazzle-php","description":"Dazzle Async SSH","archived":false,"fork":false,"pushed_at":"2017-07-23T20:19:42.000Z","size":44,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T18:38:23.250Z","etag":null,"topics":["async","dazzle","php","php-lib","php7","ssh","ssh2"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/dazzle-php.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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-06-24T21:36:25.000Z","updated_at":"2024-12-16T16:13:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"23c982de-24eb-4a21-8101-05a6cb46a3fe","html_url":"https://github.com/dazzle-php/ssh","commit_stats":null,"previous_names":["dazzle-php/ssh"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dazzle-php/ssh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dazzle-php%2Fssh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dazzle-php%2Fssh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dazzle-php%2Fssh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dazzle-php%2Fssh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dazzle-php","download_url":"https://codeload.github.com/dazzle-php/ssh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dazzle-php%2Fssh/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270148136,"owners_count":24535694,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"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":["async","dazzle","php","php-lib","php7","ssh","ssh2"],"created_at":"2024-08-01T05:01:57.029Z","updated_at":"2025-08-12T22:37:42.038Z","avatar_url":"https://github.com/dazzle-php.png","language":"PHP","readme":"# Dazzle Async SSH\n\n[![Build Status](https://travis-ci.org/dazzle-php/ssh.svg)](https://travis-ci.org/dazzle-php/ssh)\n[![Code Coverage](https://scrutinizer-ci.com/g/dazzle-php/ssh/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/dazzle-php/ssh/?branch=master)\n[![Code Quality](https://scrutinizer-ci.com/g/dazzle-php/ssh/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dazzle-php/ssh/?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/dazzle-php/ssh/v/stable)](https://packagist.org/packages/dazzle-php/ssh) \n[![Latest Unstable Version](https://poser.pugx.org/dazzle-php/ssh/v/unstable)](https://packagist.org/packages/dazzle-php/ssh) \n[![License](https://poser.pugx.org/dazzle-php/ssh/license)](https://packagist.org/packages/dazzle-php/ssh/license)\n\n\u003e **Note:** This repository is part of [Dazzle Project](https://github.com/dazzle-php/dazzle) - the next-gen library for PHP. The project's purpose is to provide PHP developers with a set of complete tools to build functional async applications. Please, make sure you read the attached README carefully and it is guaranteed you will be surprised how easy to use and powerful it is. In the meantime, you might want to check out the rest of our async libraries in [Dazzle repository](https://github.com/dazzle-php) for the full extent of Dazzle experience.\n\n\u003cbr\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/dazzle-php/dazzle/master/media/dazzle-x125.png\" /\u003e\n\u003c/p\u003e\n\n## Description\n\nDazzle SSH is a component that provides consistent interface for PHP SSH2 extension and allows asynchronous writing and reading.\n\n## Feature Highlights\n\nDazzle SSH features:\n\n* OOP abstraction for PHP SSH2 extension,\n* Support for variety of authorization methods,\n* Asynchronous SSH2 commands,\n* Asynchronous operations on files via SFTP,\n* ...and more.\n\n## Provided Example(s)\n\n### Executing commands\n\n```php\n$loop   = new Loop(new SelectLoop);\n$auth   = new SSH2Password($user, $pass);\n$config = new SSH2Config();\n$ssh2   = new SSH2($auth, $config, $loop);\n\n$ssh2-\u003eon('connect:shell', function(SSH2DriverInterface $shell) use($ssh2, $loop) {\n    echo \"# CONNECTED SHELL\\n\";\n\n    $buffer = '';\n    $command = $shell-\u003eopen();\n    $command-\u003ewrite('ls -la');\n    $command-\u003eon('data', function(SSH2ResourceInterface $command, $data) use(\u0026$buffer) {\n        $buffer .= $data;\n    });\n    $command-\u003eon('end', function(SSH2ResourceInterface $command) use(\u0026$buffer) {\n        echo \"# COMMAND RETURNED:\\n\";\n        echo $buffer;\n        $command-\u003eclose();\n    });\n    $command-\u003eon('close', function(SSH2ResourceInterface $command) use($shell) {\n        $shell-\u003edisconnect();\n    });\n});\n\n$ssh2-\u003eon('disconnect:shell', function(SSH2DriverInterface $shell) use($ssh2) {\n    echo \"# DISCONNECTED SHELL\\n\";\n    $ssh2-\u003edisconnect();\n});\n\n$ssh2-\u003eon('connect', function(SSH2Interface $ssh2) {\n    echo \"# CONNECTED\\n\";\n    $ssh2-\u003ecreateDriver(SSH2::DRIVER_SHELL)\n         -\u003econnect();\n});\n\n$ssh2-\u003eon('disconnect', function(SSH2Interface $ssh2) use($loop) {\n    echo \"# DISCONNECTED\\n\";\n    $loop-\u003estop();\n});\n\n$loop-\u003eonTick(function() use($ssh2) {\n    $ssh2-\u003econnect();\n});\n\n$loop-\u003estart();\n```\n\n### Writing files\n\n```php\n$loop   = new Loop(new SelectLoop);\n$auth   = new SSH2Password($user, $pass);\n$config = new SSH2Config();\n$ssh2   = new SSH2($auth, $config, $loop);\n\n$ssh2-\u003eon('connect:sftp', function(SSH2DriverInterface $sftp) use($loop, $ssh2) {\n    echo \"# CONNECTED SFTP\\n\";\n\n    $lines = [ \"DAZZLE\\n\", \"IS\\n\", \"AWESOME!\\n\" ];\n    $linesPointer = 0;\n\n    $file = $sftp-\u003eopen(__DIR__ . '/_file_write.txt', 'w+');\n    $file-\u003ewrite();\n    $file-\u003eon('drain', function(SSH2ResourceInterface $file) use(\u0026$lines, \u0026$linesPointer) {\n        echo \"# PART OF THE DATA HAS BEEN WRITTEN\\n\";\n        if ($linesPointer \u003c count($lines)) {\n            $file-\u003ewrite($lines[$linesPointer++]);\n        }\n    });\n    $file-\u003eon('finish', function(SSH2ResourceInterface $file) {\n        echo \"# FINISHED WRITING\\n\";\n        $file-\u003eclose();\n    });\n    $file-\u003eon('close', function(SSH2ResourceInterface $file) use($sftp) {\n        echo \"# FILE HAS BEEN CLOSED\\n\";\n        $sftp-\u003edisconnect();\n    });\n});\n\n$ssh2-\u003eon('disconnect:sftp', function(SSH2DriverInterface $sftp) use($ssh2) {\n    echo \"# DISCONNECTED SFTP\\n\";\n    $ssh2-\u003edisconnect();\n});\n\n$ssh2-\u003eon('connect', function(SSH2Interface $ssh2) {\n    echo \"# CONNECTED\\n\";\n    $ssh2-\u003ecreateDriver(SSH2::DRIVER_SFTP)\n         -\u003econnect();\n});\n\n$ssh2-\u003eon('disconnect', function(SSH2Interface $ssh2) use($loop) {\n    echo \"# DISCONNECTED\\n\";\n    $loop-\u003estop();\n});\n\n$loop-\u003eonTick(function() use($ssh2) {\n    $ssh2-\u003econnect();\n});\n\n$loop-\u003estart();\n```\n\n### Reading files\n\n```php\n$loop   = new Loop(new SelectLoop);\n$auth   = new SSH2Password($user, $pass);\n$config = new SSH2Config();\n$ssh2   = new SSH2($auth, $config, $loop);\n\n$ssh2-\u003eon('connect:sftp', function(SSH2DriverInterface $sftp) use($loop, $ssh2) {\n    echo \"# CONNECTED SFTP\\n\";\n\n    $buffer = '';\n    $file = $sftp-\u003eopen(__DIR__ . '/_file_read.txt', 'r+');\n    $file-\u003eread();\n    $file-\u003eon('data', function(SSH2ResourceInterface $file, $data) use(\u0026$buffer) {\n        $buffer .= $data;\n    });\n    $file-\u003eon('end', function(SSH2ResourceInterface $file) use(\u0026$buffer) {\n        echo \"# FOLLOWING LINES WERE READ FROM FILE:\\n\";\n        echo $buffer;\n        $file-\u003eclose();\n    });\n    $file-\u003eon('close', function(SSH2ResourceInterface $file) use($sftp) {\n        echo \"# FILE HAS BEEN CLOSED\\n\";\n        $sftp-\u003edisconnect();\n    });\n});\n\n$ssh2-\u003eon('disconnect:sftp', function(SSH2DriverInterface $sftp) use($ssh2) {\n    echo \"# DISCONNECTED SFTP\\n\";\n    $ssh2-\u003edisconnect();\n});\n\n$ssh2-\u003eon('connect', function(SSH2Interface $ssh2) {\n    echo \"# CONNECTED\\n\";\n    $ssh2-\u003ecreateDriver(SSH2::DRIVER_SFTP)\n         -\u003econnect();\n});\n\n$ssh2-\u003eon('disconnect', function(SSH2Interface $ssh2) use($loop) {\n    echo \"# DISCONNECTED\\n\";\n    $loop-\u003estop();\n});\n\n$loop-\u003eonTick(function() use($ssh2) {\n    $ssh2-\u003econnect();\n});\n\n$loop-\u003estart();\n```\n\nSee more examples in **example directory**.\n\n## Requirements\n\nDazzle SSH requires:\n\n* PHP-5.6 or PHP-7.0+,\n* UNIX or Windows OS,\n* PHP SSH2 extension enabled.\n\n## Installation\n\nTo install this library make sure you have [composer](https://getcomposer.org/) installed, then run following command:\n\n```\n$\u003e composer require dazzle-php/ssh\n```\n\n## Tests\n\nTests can be run via:\n\n```\n$\u003e vendor/bin/phpunit -d memory_limit=1024M\n```\n\n## Versioning\n\nVersioning of Dazzle libraries is being shared between all packages included in [Dazzle Project](https://github.com/dazzle-php/dazzle). That means the releases are being made concurrently for all of them. On one hand this might lead to \"empty\" releases for some packages at times, but don't worry. In the end it is far much easier for contributors to maintain and -- what's the most important -- much more straight-forward for users to understand the compatibility and inter-operability of the packages.\n\n## Contributing\n\nThank you for considering contributing to this repository! \n\n- The contribution guide can be found in the [contribution tips](https://github.com/dazzle-php/ssh/blob/master/CONTRIBUTING.md). \n- Open tickets can be found in [issues section](https://github.com/dazzle-php/ssh/issues). \n- Current contributors are listed in [graphs section](https://github.com/dazzle-php/ssh/graphs/contributors)\n- To contact the author(s) see the information attached in [composer.json](https://github.com/dazzle-php/ssh/blob/master/composer.json) file.\n\n## License\n\nDazzle SSH is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).\n\n\u003chr\u003e\n\u003cp align=\"center\"\u003e\n\u003ci\u003e\"Everything is possible. The impossible just takes longer.\"\u003c/i\u003e ― Dan Brown\n\u003c/p\u003e\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdazzle-php%2Fssh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdazzle-php%2Fssh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdazzle-php%2Fssh/lists"}