[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

Access file over network with username and password

Is it possible to connect to a network file share over a network with a different username and password other than www-data.

I've got a ubuntu web server, but not much storage space, however on the same network I've got 4TB available but only network sharing with usernames and passwords.

I need to be able to read write to the share if possible as well. I can access via FTP if needed though.
0
tonelm54
Asked:
tonelm54
  • 3
  • 2
  • 2
1 Solution
 
tonelm54Author Commented:
What Im hoping is a way of doing something similar to:-
	$data = file_get_contents('//username:password@server/myShare/myFolder/myFile.dat');
	
	echo $data;

Open in new window


So in real terms:-
	$data = file_get_contents('//tcross:64TTyr6@192.168.1.55/storage/myWebStore1/file0006.dat');
	
	echo $data;

Open in new window

0
 
Julian HansenCommented:
Why do you want to connect via the webserver - why not mount the network share to the system as an admin at which point it will be available to your web server?
0
 
Ray PaseurCommented:
You might be able to do this with cURL.  Please set up the test data URL (a portion of the  SSCCE) and tell us what credentials you want us to use.  I'll be glad to make a test and show you the results.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
Julian HansenCommented:
You might be able to do this with cURL.
Only if there is a web service listening on the other side. I interpret the question as requiring file access to a file on a remote share - in which case cUrl is not viable.
0
 
Ray PaseurCommented:
@julianH: I'll wait for the author to post the credentials before I give up on any particular solution.  

I may be missing something of the economics in this question, since a gigabyte of storage can be purchased for the cost of a few sheets of toilet paper.  To me it would seem obvious and easy to just add storage to the web server.
0
 
tonelm54Author Commented:
Unfortunately I'm stuck with the host size, I cannot increase it. However I do have several TB on another server Im able to use. My thought is at the moment is to use FTP to copy the file into a temporary store on the host then serve it as needed.
0
 
Julian HansenCommented:
Is the other server only accessible via FTP or is it possible to mount the remote volume on your http server?

Do the contents of the files change?

If not then you might want to consider implementing a file caching solution - where the files that are requested the most frequently are cached on the server to boost performance - having to wait for an FTP connect and transfer could degrade overall performance of your site.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now