dqpfl2508589 2019-07-12 14:57
浏览 100
已采纳

如何从Ubuntu中的Laravel应用程序访问Windows服务器中的文件?

I need to connect through ssh from a Laravel application hosted in Ubuntu to a Windows server where I want to retrieve some files in order to use them within my application.

The Laravel Application is hosted in Ubuntu with nginx 1.14 and using PHP 7.3.6 and Laravel 5.8.

The files I need to use (By 'use' I mean read, edit, download and upload) in Laravel need to stay in that Windows server because moving them to Linux would be too much of a hassle for the people who create these files (Excel worksheets, text files, csv files) and for me because I would have to configure the samba shared folders on every PC here.

I have tried using ssh to connect to the Windows server and it shows the login prompt but no credentials are working (It's within a domain and I've tried with 'domain\username' but to no effect :( ).

Summary

  • Files in Windows server: xlsx, csv, txt
  • Operations: read, edit, donwload, upload.
  • Laravel application is hosted in Ubuntu.
  • Can't connect through ssh from Ubuntu to Windows server.

  • Ubuntu server configuration:

    • Ubuntu 18.04
    • Nginx 1.14.0
    • Laravel 5.8
    • PHP 7.3.6

My login attempts:

sys@server:~$ sudo ssh arebollar@xx.xx.xx.xx
arebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

arebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

arebollar@xx.xx.xx.xx's password:
Received disconnect from xx.xx.xx.xx port 22:2: Too many attempts.
Disconnected from xx.xx.xx.xx port 22


sys@server:~$ sudo ssh AzureAD\arebollar@xx.xx.xx.xx
AzureADarebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

AzureADarebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

AzureADarebollar@xx.xx.xx.xx's password:
Received disconnect from xx.xx.xx.xx port 22:2: Too many attempts.
Disconnected from xx.xx.xx.xx port 22


sys@server:~$ sudo ssh domain\arebollar@xx.xx.xx.xx
domainarebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

domainarebollar@xx.xx.xx.xx's password:
Permission denied, please try again.

domainarebollar@xx.xx.xx.xx's password:
Received disconnect from xx.xx.xx.xx port 22:2: Too many attempts.
Disconnected from xx.xx.xx.xx port 22
  • 写回答

1条回答 默认 最新

  • drx3157 2019-07-16 15:10
    关注

    I'm posting this answer for anyone who is struggling with an issue like mine.

    I finally solved this using ftp, accesing the files like this:

    Storage::disk('ftp')->files($this->filePath.$filename)
    

    I added a ftp local disk in config/filesystems.php:

    'disks' => [
    
            'local' => [
                'driver' => 'local',
                'root' => storage_path('app'),
            ],
    
    ...
    
            'ftp' => [
                'driver'   => 'ftp',
                'host'     => env('FTP_HOST'),
                'username' => env('FTP_USERNAME'),
                'password' => env('FTP_PASSWORD'),
            ],
    

    And finally added the ftp parameters to the .env file and ran:

    php artisan config:cache
    

    Hope this helps someone else. :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?