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 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题