SFTP Public Key Authentication
Using one of our import/export modules and need to connect to a SFTP server that uses pubkey authentication? That means, you need to supply a private key in order to log into the SFTP server?
While it's not an official feature of the extensions, there is sample code in each of the extensions on how to make it happen. Not configurable from the Magento backend, but you can set it up.
You can either directly put the key into the specific class mentioned below, or you can set up a preference ("rewrite") so you can move the class into a custom module (better to upgrade the module later on) and put in the customized pubkey code there.
Let's take the Xtento_OrderExport extension as an example. Open the file: app\code\Xtento\OrderExport\Model\Destination\Sftp.php
There are a few things you'll need to do:
- Convert your private key into a format phpseclib understands. This is PKCS1 as far as we know.
- Uncomment line 39 through 54 (may change in future versions, but on above screenshot you can see the part to uncomment)
- Line 43-48 place your private key there, or write a function that loads it from a file (Example on line 41)
- Comment line 56
- Uncomment line 57
The same principle applies for all our import/export extensions. Just open the Source\Sftp or Destination\Sftp class in the correct module.
Do note that the SFTP library that comes with Magento supports certain SFTP versions only. That is, as far as we know, SFTPv2 and SFTPv3.