1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

phpseclib の Net_SSH2 でエージェント認証

Last updated at Posted at 2014-03-05

System_SSH_Agent が psr-0 のディレクトリ構成になっていないので composer から入れるとオートロードされない(クラス名の区切りがディレクトリ区切りになっていない)。

include-path が通っているので require_once で明示的に読みこめば大丈夫。

<?php
require_once 'vendor/autoload.php';
require_once 'System/SSH_Agent.php';

$agent = new System_SSH_Agent();
$ssh = new Net_SSH2('example.net');

if (!$ssh->login('your', $agent))
{
    exit('Login Failed');
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?