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

如何从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

图片转代码服务由CSDN问答提供 功能建议

我需要通过ssh从Ubuntu中托管的Laravel应用程序连接到我想要检索某些文件的Windows服务器 为了在我的应用程序中使用它们。

Laravel应用程序托管在Ubuntu中,使用nginx 1.14并使用PHP 7.3.6和Laravel 5.8。

我需要使用的文件(通过'使用',我的意思是阅读,编辑,下载和上传)需要留在Windows服务器中,因为将它们移动到Linux对于创建这些文件的人来说太麻烦了 (Excel工作表,文本文件,csv文件)对我来说因为我必须在这里配置每台PC上的samba共享文件夹。

我尝试使用ssh连接到Windows服务器 它显示登录提示但没有凭据正在运行(它在一个域内,我尝试使用'domain \ username'但没有效果:()。

摘要

  • Windows服务器中的文件:xlsx,csv,txt
  • 操作:读取,编辑,下载,上传。
  • Laravel应用程序托管在Ubuntu中。
  • 无法通过ssh从Ubuntu连接到Windows服务器 。

  • Ubuntu服务器配置:

    • Ubuntu 18.04
    • Nginx 1.14 .0
    • Laravel 5.8
    • PHP 7.3.6

      我的登录尝试:

        sys @ server:〜$ sudo ssh arebollar@xx.xx.xx.xx 
      arebollar@xx.xx.xx.xx的密码:  
      许可被拒绝,请再试一次。
       
      arebollar@xx.xx.xx.xx的密码:
      许可被拒绝,请再试一次。
       
       
      narebollar@xx.xx.xx.xx的密码:
      已接受与xx的断开连接。  xx.xx.xx端口22:2:尝试次数过多。
      从xx.xx.xx.xx端口22 
       
       
      sys @ server断开连接:〜$ sudo ssh AzureAD \ arebollar@xx.xx.xx.xx  
      AzureADarebollar@xx.xx.xx.xx的密码:
      许可被拒绝,请再试一次。
       
      AzureADarebollar@xx.xx.xx.xx的密码:
      许可拒绝,请再试一次。
       
      AzureADarebollar@xx.xx  .xx.xx的密码:
      已从x断开连接 x.xx.xx.xx端口22:2:尝试次数过多。
      从xx.xx.xx.xx端口22 
       
       
      sys @ server断开连接:〜$ sudo ssh domain \ arebollar@xx.xx.xx  .xx 
      domainarebollar@xx.xx.xx.xx的密码:
      许可被拒绝,请再试一次。
       
      domainarebollar@xx.xx.xx.xx的密码:
      许可被拒绝,请再试一次。
       
      domainarebollar @ xx  .xx.xx.xx的密码:
      已从xx.xx.xx.xx端口22:2接收断开连接:尝试次数过多。
      从xx.xx.xx.xx端口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. :)

    点赞 打赏 评论

相关推荐 更多相似问题