Skip to content

Package and host requirements? #80

@if-nick

Description

@if-nick

Could you share host or server requirements for using this library? Is a php ssh extension required?

On our host env we have ssh:

$ whereis ssh
ssh: /usr/bin/ssh /etc/ssh /usr/share/man/man1/ssh.1.gz

But on a web page on the host we do not. For example:

<?php 
/***
 * https://..../test.php
 */
echo exec("which ssh");
// No output.

Similar results after installing the library. The Process result is statuscode 127, command not found:

<?php

namespace Drupal\my_test\Controller;

use GuzzleHttp\ClientInterface;
use Symfony\Component\Process\Process;
use Spatie\Ssh\Ssh;

/**
 * Fetch a token.
 */
class GetSSHToken {

  /**
   * Fetch the SSH result.
   */
  public static function test() {

    dump([
      exec("ssh"),
      exec("which ssh"),
    ]);

    $process = Ssh::create($sshUser, $sshHost)
      ->usePort($sshPort)
      ->usePrivateKey($sshKeyPath)
      ->disableStrictHostKeyChecking()
      ->execute('token');

    dump([
      $process,
      $process->isSuccessful(),
      $process->getOutput(),
    ]);
    $process = Ssh::create($sshUser, $sshHost)
      ->usePort($sshPort)
      ->usePrivateKey($sshKeyPath)
      ->disableStrictHostKeyChecking()
      ->execute('token');

    dump([
      $process,
      $process->isSuccessful(),
      $process->getOutput(),
    ]);

  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions