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 综合布线实例设计,就好看好看不恐怖可好滤镜好聚
  • ¥15 使用moviepy库视频合并时出错
  • ¥30 FLUENT液固传质UDF
  • ¥15 怎么看梯度直方图以,怎么判断梯度消失/爆炸,怎么解决
  • ¥15 aspnetdll文件访问拒绝
  • ¥15 wpf中在模版中寻找元素
  • ¥15 MFC平台生成指定圆
  • ¥15 jmeter出现403
  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关