27 lines
879 B
PHP
27 lines
879 B
PHP
<?php
|
|
|
|
namespace App\Services\Ssh;
|
|
|
|
/**
|
|
* A connected SSH session to a single host. Implementations are stateful:
|
|
* connect once, then run/putFile against that connection.
|
|
*/
|
|
interface RemoteShell
|
|
{
|
|
public function connectWithPassword(string $host, string $user, string $password): void;
|
|
|
|
/**
|
|
* Connect with a private key. When $expectedFingerprint is non-empty the
|
|
* server host key must match it, otherwise the connection is rejected
|
|
* (host-key pinning).
|
|
*/
|
|
public function connectWithKey(string $host, string $user, string $privateKey, ?string $expectedFingerprint = null): void;
|
|
|
|
public function run(string $command): CommandResult;
|
|
|
|
public function putFile(string $remotePath, string $contents): void;
|
|
|
|
/** SSH host key fingerprint of the connected server (for pinning). */
|
|
public function hostKeyFingerprint(): string;
|
|
}
|