framework: the privateKey could not use on SFTP

  • Laravel Version: 5.7.17
  • PHP Version: 7.2.12
  • Database Driver & Version: Mysql 5.7.24

Description:

the privateKey could not use on SFTP, but password can do

Steps To Reproduce:

config/filesystems.php

        'main_dir' => [
            'driver' => 'sftp',
            'host' => '***',
            'username' => 'root',
            'privateKey' => '/var/id_rsa',  // file permissions was ok
            'password' => '*****',
        ],

that could not login… but use sftp root@**** -i/var/id_rsa ok

but use password could login…

        'main_dir' => [
            'driver' => 'sftp',
            'host' => '***',
            'username' => 'root',
            //'privateKey' => '/var/id_rsa',  // file permissions was ok
            'password' => '*****',
        ],

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (10 by maintainers)

Most upvoted comments

I use it this way:

    'SFTP' => [
      'driver' => 'sftp',
      'host' => '0.0.0.0',
      'username' => 'admin',
      'privateKey' => '-----BEGIN RSA PRIVATE KEY-----000000000000000000000000000000-----END RSA PRIVATE KEY-----',
      'root' => '/',
      'timeout' => 10
    ],

When i use with password it doesn’t work for me. Also i couldn’t get the privateKey file reference to work so i use the contents of it directly (i think this is also a tiny bit more performant).

I also suggest you use the cache option so the server doesn’t have to re-auth every time you call the disk.

composer require league/flysystem-cached-adapter

    'SFTP' => [
      'driver' => 'sftp',
      'host' => '0.0.0.0',
      'username' => 'admin',
      'privateKey' => '-----BEGIN RSA PRIVATE KEY-----000000000000000000000000000000-----END RSA PRIVATE KEY-----',
      'root' => '/',
      'timeout' => 10,
      'cache' => true
    ],

…The key was wrong…That my mistakes… I change an other key…That worded…Sorry for wasting your time… Thanks for your help…