dqy0707 2019-02-04 14:07
浏览 48

使用phpseclib使用ECDSA客户端证书登录SFTP服务器

I'm trying to log into an SSH server using a ECDSA client certificate in PHP. I'm using the master dev branch of phpseclib which includes support for ECDSA since October 2018.

I've taken the sample script for logging into an ssh server, and adapted it to use my certificate:

use phpseclib\Crypt\ECDSA;
use phpseclib\Net\SFTP;

$sftp = new SFTP('server.ssh');
$key = new ECDSA();

echo $key->load(file_get_contents('/path/to/clientkey'));

if (!$sftp->login('username', $key)) {
    print_r($sftp->getErrors());
    echo 'Login Failed';
} else {
    echo 'Login Succeeded!';
}

This code yields the following pretty much instantaneously (so no timeout):

1 // so the key loads successfully

Array
(
) // no errors that we know of
Login Failed // but no success either

The same login data works using sftp command line on the same machine. The remote server only supports SFTP connections, so I can't try a regular SSH2 connection.

Is this supposed to work yet? Is this how it's supposed to work, or is there an error in my code?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度