gpt4 book ai didi

ssh - phpseclib ssh 登录失败,没有错误

转载 作者:行者123 更新时间:2023-12-02 14:30:10 25 4
gpt4 key购买 nike

这是我的代码:

error_reporting(E_ALL);
require __DIR__ . '/vendor/autoload.php';

use phpseclib\Net\SSH2;
use phpseclib\Crypt\RSA;

$ssh = new SSH2('stg.net');
$key = new RSA();
$key->loadKey(file_get_contents('/Users/me/.ssh/my_private_key'));
if (!$ssh->login('username', $key)) {
print_r($ssh->getLastError());
print_r($ssh->getErrors());
exit('Login Failed');
}

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

输出:
Array
(
)

vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.phpfunction _privatekey_login($username, $privatekey)
$publickey = $privatekey->getPublicKey(RSA::PUBLIC_FORMAT_RAW);
if ($publickey === false) {
return false;
}

我收到 false ,也许我也必须设置公钥?如何做呢?
如何调试它?

+++ 更新+++

我也尝试了这些票的建议/提示:

phpseclib always gives login failed with no log

Net/SSH2 - phpseclib login failing - error: "failedArray"

最佳答案

问题是所讨论的 key 是 ECDSA key 。报价 https://github.com/phpseclib/phpseclib/issues/1082#issuecomment-396122366 :

My library supports EdDSA keys in the OpenSSH format (ie. the kindthat ssh-keygen would generate), the PuTTY format (ie. the kindputtygen would generate), in libsodium format and in the formatspecified in this IETF Draft:

https://datatracker.ietf.org/doc/html/draft-ietf-curdle-pkix-07

If libsodium / sodium_compat are being used the keys are convertedfrom whatever format they were in to the libsodium format tofacilitate libsodium's use.

Encrypted OpenSSH private keys are not supported for the same reasonsodium_compat does not support Argon2i - it's too slow. OpenSSH uses acustom form of bcrypt that does bcrypt 128 times as I recall andencrypts a different string etc so PHP's bcrypt implementation cannotbe used and since bcrypt uses a custom key expansion OpenSSL'simplementation of Blowfish can't be used either.


在这里,作者谈论的是 EdDSA——不是 ECDSA——但从帖子的其余部分来看,听起来像素数有限域上的 ECDSA 也是完整的。
引用该帖子后面的帖子:

Also, I'm not ready to make my code public yet. I just thought I'd post a progress report for anyone interested.


我的猜测是这个实现将存在于 master 分支而不是 2.0 分支中。我这么说是因为 DSA 更改是在主分支而不是 2.0 分支中。最终,主分支(据我所知)将变为 3.0.0,但在这种情况发生时会出现 idk。

关于ssh - phpseclib ssh 登录失败,没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50901953/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com