2

I am trying to upload a file over sftp using laravel.

Here's SFTP configuration:

SFTP_HOST=X.X.X.X
SFTP_USERNAME=root
SFTP_PASSWORD=
SFTP_KEY_PATH=/root/usr/es_server.pem

config > filesystems.php

'sftp' => [
        'driver' => 'sftp',
        'host'     => env('SFTP_HOST'),
        'port'     => 22,
        'username' => env('SFTP_USERNAME'),
        'root' => '/uploads/', 
        'privateKey' => env('SFTP_KEY_PATH'),
        'visibility' => 'public',
        'permPublic' => 0755,
        'directoryPerm' => 0755
    ]

This is working properly on my local, with the same host and key.

But from deployed server, I get this

"Could not login with username: root, host: x.x.x.x"

Logging into the deployed server, and connecting the host server over sftp is working for the root user and the same key.

root@dma:~# sftp -i es_server.pem root@x.x.x.x
Connected to x.x.x.x
sftp> 

I checked for firewalls on the host server if it is blocking the deployed server but no blocks found.

What could be the issue? What am I missing?

Azima
  • 3,415
  • 5
  • 27
  • 58
  • Possible duplicate of [MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)](https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw) – SuRo Jun 03 '19 at 09:22

1 Answers1

3

Finally found the issue.

The application was denied the access to key path as defined in SFTP_KEY_PATH.

I set the path to some where the application can access the key.

In my case, SFTP_KEY_PATH=/var/www/html/dma/es_key.pem.

Azima
  • 3,415
  • 5
  • 27
  • 58