Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

popotte93's avatar

[ Laravel 10 ] Issue with flysystem SFTP with OPENSSH privateKey

Hello :)

I have a problem with my SFTP

When I try to put a file I have an error saying: Unable to load private key. I didnt have this problem when I was in Laravel 8

I searched a little and found that since Laravel9 OPENSSH keys dont works and need RSA keys

But I cant change the private key :/

So there is a solution to make it works? Or there are another libraries I can use instead of Flysystem v3 who accepts openssh keys? I tried to install Flysystem v1, but laravel/framework 10 requires flysystem v3 :(

Thanks :)

		'driver' => 'sftp',
        'host' => 'my-host',
        'port' => 3622,
        'username' => 'the-username',
        'privateKey' => env('FILESYSTEM_RSA_KEY'),
        'timeout' => 300,
        'root' => 'root',
        'throw' => true,
0 likes
3 replies
alden8's avatar
alden8
Best Answer
Level 1

@popotte93 -- converting OPENSSH key to RSA format:

--- if possible, consider converting your OPENSSH private key to RSA format. This would eliminate incompatibility issues with Flysystem v3

--- use tools like ssh-keygen or puttygen to perform the conversion

--- ensure proper permissions for the converted key file

-- exploring alternative libraries if key conversion isn't feasible, investigate alternative libraries that support OPENSSH keys:

--- phpseclib: A comprehensive PHP security library with SFTP support for various key formats

--- phpseclib-sftp: A standalone SFTP library based on phpseclib

--- league/flysystem-sftp: A Flysystem adapter for SFTP, compatible with both Flysystem v1 and v3

-- may be addressing configuration problem. Double-check your Laravel SFTP configuration in config/filesystems.php:

--- ensure correct paths to the private key and passphrase (if applicable)

--- verify other settings like host, username, port, etc

--- enable detailed logging to capture specific error messages

-- more fo debug:

--- test SFTP connection using command-line tools like sftp to isolate library-specific issues

--- experiment with different key formats (PEM, PKCS8)

--- check file and directory permissions on both local and remote servers

--- consider using an SFTP client for direct file transfers and testing

popotte93's avatar

Hello :)

Convert to RSA works, thanks !! :D

1 like

Please or to participate in this conversation.