Download the PHP package luka/php-ssh without Composer
On this page you can find all versions of the php package luka/php-ssh. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-ssh
PHP SSH
Provides an object-oriented wrapper for the php ssh2 extension. This is based on the work of Antoine Hérault.
Requirements
You need PHP version 7.1+ with the SSH2 extension.
Installation
The best way to add the library to your project is using composer.
$ composer require luka/php-ssh:^2.0
Usage
Configuration of the connection
To establish an SSH connection, you must first define its configuration. For that, create a Configuration instance with all the needed parameters.
The available configuration classes are:
Ssh\HostConfiguration
Ssh\OpenSSH\ConfigFile
Both connection configuration and public/private key authentication can be obtained from a ssh config file such as ~/.ssh/config
Create a session
The session is the central access point to the SSH functionality provided by the library.
Authentication
The authentication classes allow you to authenticate over a SSH session. When you define an authentication for a session, it will authenticate on connection.
The available authentication are:
None
for username based authenticationPassword
for password authenticationPublicKeyFile
to authenticate using a public keyHostBasedFile
to authenticate using a public hostkeyAgent
to authenticate using an ssh-agent
Authentication from Ssh\OpenSSH\ConfigFile
If you use an ssh config file you can load your authentication and configuration from it as follows:
This will pick up the username, and your public and private keys from your config file Host and Identity declarations.
This simple snippet only works if the User
declaration is also present, and the private key does
not require a pass phrase. If any of this is not the case you have to pass the missing values to
the createAuthentication()
method.
Subsystems
Once you are authenticated over a SSH session, you can use the subsystems.
Sftp
You can easily access the sftp subsystem of a session using the getSftp()
method:
See the Ssh\Sftp
class for more details on the available methods.
Publickey
The session also provides the getPublickey()
method to access the publickey subsystem:
The Public-Key subsystem allows you to provide multiple public keys to use for authentication.
See the Ssh\Publickey
class for more details on the available methods.
Exec
The session provides the getExec()
method to access the exec subsystem
See the Ssh\Exec
class for more details.
All versions of php-ssh with dependencies
ext-ssh2 Version ^1.0