'Connect to SFTP with .ppk private key in CodeIgniter

I'm trying to connect from CodeIgniter to SFTP server. But this SFTP uses a private key with a .ppk extension.

The general code is

$sftp_config['hostname'] = 'your.sftp-domain.com';
$sftp_config['username'] = 'your_sftp_username';
$sftp_config['password'] = 'your_sftp_password';
$sftp_config['debug'] = TRUE;`

How about config using private key?

Full code example using private key to connect on SFTP server.



Solution 1:[1]

I do not know CodeIgniter. And briefly checking it, it actually do not seem to support SFTP out-of-the-box. You must be using some 3rd party plugin. And chances are that the plugin does not support PPK keys, as that's a proprietary format of PuTTY client.

Anyway, it's not true that "this sftp uses a private key with a .ppk extension". The server does not care, what format of the key you use locally. So just covert the key to the format that your local SFTP client library supports. That's most probably the OpenSSH format. Use PuTTYgen to covert the key.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin Prikryl