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

AtomCoder's avatar

User Defined FTP Servers

Hi,

I'm looking to add functionality to my website to allow users to upload their "Public" ssh keys to allow them use there own FTP servers (via Filesystem) within there accounts.

Currently I can only see documentation on Laravel to allow adding "Private" keys.

Is this possible?

0 likes
6 replies
Snapey's avatar
Snapey
Best Answer
Level 122

I don't believe you can log into the user's ftp server with their public key.

What should happen is that you ask the client to create an account for your server on their SFTP server and you give them YOUR public key so that you can operate as a client to their server.

Regarding Laravel setup, this is what I do;

$filesystem = Storage::createSFtpDriver([
                'host'     => $system->ftphost,
                'username' => decrypt($system->ftpuser),
                'password' => decrypt($system->ftppass),
                'port'     => '22',
                //'root'     => '',
                // 'passive'  => true,
                // 'ssl'      => true,
                'timeout'  => '10',
            ]);

// example use

$files = collect($filesystem->listContents($system->ftppath, false));

here I am getting the credentials from a model (system) which could be per customer. The username and password is encrypted in the DB.

More info on the Fly system site https://flysystem.thephpleague.com/docs/adapter/sftp-v3/

1 like
AtomCoder's avatar

@Snapey Thanks for that. That clears it up very well.

Just on the "decrypt". What method of encryption are you using when storing the users credentials? Normal password hash?

Please or to participate in this conversation.