{"id":13519697,"url":"https://github.com/Herzult/php-ssh","last_synced_at":"2025-03-31T14:30:59.825Z","repository":{"id":47051418,"uuid":"1533483","full_name":"Herzult/php-ssh","owner":"Herzult","description":"An experimental object oriented SSH api in PHP","archived":false,"fork":false,"pushed_at":"2023-05-11T20:27:20.000Z","size":113,"stargazers_count":359,"open_issues_count":27,"forks_count":82,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-11-02T02:33:18.415Z","etag":null,"topics":[],"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/Herzult.png","metadata":{"files":{"readme":"README.markdown","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":"2011-03-27T18:02:01.000Z","updated_at":"2024-09-07T09:32:45.000Z","dependencies_parsed_at":"2024-11-02T02:30:54.410Z","dependency_job_id":"e2d74ff3-0919-4740-961f-76efa8010a2d","html_url":"https://github.com/Herzult/php-ssh","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Herzult%2Fphp-ssh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Herzult%2Fphp-ssh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Herzult%2Fphp-ssh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Herzult%2Fphp-ssh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Herzult","download_url":"https://codeload.github.com/Herzult/php-ssh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246482924,"owners_count":20784798,"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":[],"created_at":"2024-08-01T05:02:02.082Z","updated_at":"2025-03-31T14:30:59.570Z","avatar_url":"https://github.com/Herzult.png","language":"PHP","readme":"PHP SSH\n=======\n\n[![Build Status](https://travis-ci.org/Herzult/php-ssh.png?branch=master)](https://travis-ci.org/Herzult/php-ssh) (master)\n\nProvides an object-oriented wrapper for the php ssh2 extension.\n\nRequirements\n------------\n\nYou need PHP version 5.3+ with the [SSH2 extension](http://www.php.net/manual/en/book.ssh2.php).\n\nInstallation\n------------\n\nThe best way to add the library to your project is using [composer](http://getcomposer.org).\n\n    $ composer require herzult/php-ssh:~1.0\n\nUsage\n-----\n\n### Configuration of the connection\n\nTo establish an SSH connection, you must first define its configuration.\nFor that, create a Configuration instance with all the needed parameters.\n\n```php\n\u003c?php\n\n// simple configuration to connect \"my-host\"\n$configuration = new Ssh\\Configuration('my-host');\n```\n\nThe available configuration classes are:\n\n- `Configuration`\n- `SshConfigFileConfiguration`\n\nBoth connection configuration and public/private key authentication can be obtained from a ssh config file such as `~/.ssh/config`\n\n```php\n\u003c?php\n\n// simple configuration to connect \"my-host\"\n$configuration = new Ssh\\SshConfigFileConfiguration('/Users/username/.ssh/config', 'my-host');\n$authentication = $configuration-\u003egetAuthentication('optional_passphrase', 'optional_username');\n```\n\n### Create a session\n\nThe session is the central access point to the SSH functionality provided by the library.\n\n```php\n\u003c?php\n\n// ... the configuration creation\n\n$session = new Ssh\\Session($configuration);\n```\n\n### Authentication\n\nThe authentication classes allow you to authenticate over a SSH session.\nWhen you define an authentication for a session, it will authenticate on connection.\n\n```php\n\u003c?php\n\n$configuration = new Ssh\\Configuration('myhost');\n$authentication = new Ssh\\Authentication\\Password('John', 's3cr3t');\n\n$session = new Session($configuration, $authentication);\n```\n\nThe available authentication are:\n\n - `None` for username based authentication\n - `Password` for password authentication\n - `PublicKeyFile` to authenticate using a public key\n - `HostBasedFile` to authenticate using a public hostkey\n - `Agent` to authenticate using an ssh-agent\n\n### Authentication from SshConfigFileConfiguration\n\nIf you use an ssh config file you can load your authentication and configuration from it as follows:\n\n```php\n\u003c?php\n\n$configuration = new Ssh\\SshConfigFileConfiguration('~/.ssh/config', 'my-host');\n\n$session = new Session($configuration, $configuration-\u003egetAuthentication());\n```\n\nThis will pick up your public and private keys from your config file Host and Identity declarations.\n\n### Subsystems\n\nOnce you are authenticated over a SSH session, you can use the subsystems.\n\n#### Sftp\n\nYou can easily access the sftp subsystem of a session using the `getSftp()` method:\n\n```php\n\u003c?php\n\n// the session creation\n\n$sftp = $session-\u003egetSftp();\n```\n\nSee the `Ssh\\Sftp` class for more details on the available methods.\n\n#### Publickey\n\nThe session also provides the `getPublickey()` method to access the publickey subsystem:\n\n```php\n\u003c?php\n\n// ... the session creation\n\n$publickey = $session-\u003egetPublickey();\n```\n\nSee the `Ssh\\Publickey` class for more details on the available methods.\n\n#### Exec\n\nThe session provides the `getExec()` method to access the exec subsystem\n\n```php\n\u003c?php\n\n// ... the session creation\n\n$exec = $session-\u003egetExec();\n\necho $exec-\u003erun('ls -lah');\n```\n\nSee the `Ssh\\Exec` class for more details.\n","funding_links":[],"categories":["PHP","安全","目录","Table of Contents","安全 Security","Security","安全( Security )"],"sub_categories":["安全 Security","Security"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHerzult%2Fphp-ssh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHerzult%2Fphp-ssh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHerzult%2Fphp-ssh/lists"}