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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵