0

I'm trying to connect via sftp to my server with private key (.ppk file and ssh-dss) in PHP

The problem is that the private key is ssh-dss not RSA.

I tried to use phpseclib with this code but doesn't work (RSA I suppose)

set_include_path(get_include_path() . PATH_SEPARATOR . 'lib/phpseclib');
include('Net/SSH2.php');
include('Crypt/RSA.php');

$rsa = new Crypt_RSA();
$rsa->setPassword('my-pass-phrase');
$content = file_get_contents('key/private.ppk');
$rsa->loadKey($content);
$ssh = new Net_SSH2('host');
if (!$ssh->login('username', $rsa)) {
    exit('Login Failed');
}

Thanks

  • No, putting DSA key into RSA will not work. – Jakuje Aug 17 '17 at 09:57
  • phpseclib's master branch has DSA support: https://github.com/phpseclib/phpseclib/pull/1090 BUT I don't think SSH2 has been updated to support the new DSA keys yet. I also wouldn't recommend using the master branch atm anyway as backwards comparability isn't guaranteed from commit to commit. Most notably, it was `$rsa->loadKey()` in 1.0 and 2.0 but in master it's `$rsa->load()`. – neubert Aug 17 '17 at 12:32

0 Answers0