I have to connect to a SFTP server. I used first this code :
$Key = new RSA();
$Key->setPassword("password");
$Key->loadKey(file_get_contents('path_to_RSA_private_key'));
$sftp = new SFTP($IP_addr, $port_number);
if (!$sftp->login('username', $Key))
echo date('Y/m/d H:i:s').' SFTP login failed to $IP_addr';
It worked well. I know phpseclib uses default sha1 and I would like to use sha256. So I tried with that code :
$Key = new RSA();
$Key->setHash('sha256');
$Key->setMGFHash('sha256');
$Key->setPassword("password");
$Key->loadKey(file_get_contents('path_to_RSA_private_key'));
$sftp = new SFTP($IP_addr, $port_number);
if (!$sftp->login('username', $Key))
echo date('Y/m/d H:i:s').' SFTP login failed to $IP_addr';
But it doesn't work. I got that message on server :
error: key_verify: invalid format
If necessary, I can send debug logging on server side. This server uses default values for Ciphers, KexAlgorithms and MACs parameters.
Thanks for help.