Jump to content

Sharing files across the network [solved]


neddie
 Share

Recommended Posts

This is perhaps a dumb question, but can anyone point me towards a basic guide to sharing files between computers over a local network?

What I've got, since recently, is the following:

- A modem connected to the internet via cable

- A router (from Netgear) connected to the modem

- A Windows box connected to the router by a network cable

- A linux laptop connected to the router by a network cable

 

Both machines can now access the internet, independently and simultaneously. So far so good. Now I'd like a simple way to transfer files between the computers using the network, so what do I need to set up?

 

The way I see it, either I need to "share" a directory on the windows machine and access it from the linux box (with read/write permissions), or I need to "share" a directory on the linux box and access it from the windows box. I don't really care which way round it is, whichever is easier. Although it would be nice to have a way which was not windows-reliant so that when (if) the windows box gets converted, the file-sharing still works.

 

One thing I want to make sure of is that when the directory is "shared", I want to be sure that it's only shared between these two computers, not made publicly accessible or readable from the other side of the router. Is this controlled by the sharing mechanism or by some settings on the router?

 

By the way, the router pulls an IP address automatically by DHCP, and currently both the windows and linux machines also pull IP addresses from the router.

Edited by neddie
Link to comment
Share on other sites

The DHCP thing makes it harder.

I propose to you two solutions:

— Use Unison to synchronize; this is not sharing, but duplicating. It is however cross-platform, and that way any of the two computers still has all files when the other is powered down (you know, to save the Earth).

— Setup Samba on your Linux box: this is quite easy, and you can filter who (and from where) can access each share. When Windows disapears (“gets convertedâ€), samba is universally handled across all Linux distributions, and not a bad choice at that.

 

Yves.

Link to comment
Share on other sites

Your netgear router should have firewall functionality, and therefore unless you open incoming access to the particular ports in question, nobody should be able to gain access to your internal systems.

 

With DHCP, means you can set hostnames in /etc/hosts or c:\windows\system32\drivers\etc\hosts so that each machine knows how to resolve the machine name to the IP. So, you could use static IP's, or on the router you should have the functionality to be able to allocate the same IP address to a particular mac address of the network cards, so that effectively, each time each machine asks for an ip address, they'll always get the same one - almost like static ip without having to specify directly and manually on each computer. Bonus, if you clean reinstall, whatever OS you put will always pull the same IP address, unless of course, you change the network card :)

 

samba would be good enough, but you could always consider webdav perhaps and use a webdav client from both machines. Nautilus in gnome can do it automatically and you can just mount it, Windows I've not tried, but I'm sure there is a client that's easy to find and free too.

 

Samba can be setup dead easy under Mandriva if you have drakwizard installed, or alternatively, you could install swat, and then configure via web browser with the swat interface. Drakwizard also has wizard for webdav too.

Link to comment
Share on other sites

Thanks for the tips!

 

So it sounds to me like the easiest way is to share a linux directory using samba. Now I've got 2008.1 running, with a lovely wizard in mcc to set everything up for me.

I created a new directory under /usr/ and gave everybody wrx rights. Then in the wizard I specified this directory as the only share, with a user level authorization, one user and password. I wasn't sure what the "workgroup" was or whether it matters, but the wizard seemed happy with the entry. So far so good.

Now I go to the windows machine, and try to map a drive to \\ip.addr.ess\external and expect it to give me a dialog for username and password. Instead, it just gives me an egg timer, and the linux box complains about a "port scan" from the windows box... odd, but ok. I click the "whitelist" button which adds the windows machine's IP address to the whitelist, but the windows machine still says "network path \\ip.addr.ess\external not found". And when I just try to browse the "entire network" on the windows machine, it just sits there...

 

Any ideas what's wrong? Could it be this "workgroup" thing which is limiting the visibility of my share? Or could it be because my security setting is set to "high" (the default by install) ?

Link to comment
Share on other sites

Normally you would configure samba and the Windows computers with the same workgroup. This helps better for when trying to map drives, etc, and seeing the machines on the network if they are in the same workgroup, although it's not mandatory. Just seems to perform better when I've done it with just one workgroup.

 

Also, check that shorewall/iptables or something isn't blocking your access to the machine - the portscan thing makes it sound like some service is causing issues.

Link to comment
Share on other sites

Nearly there! :thumbs:

In the "security" section of the mcc I went into "Set up your personal firewall" and ticked the checkbox for "allow the internet to connect to windows file sharing (SMB)". Then I tried to map the network drive again and this time it worked, I can read the files from the windows machine and copy them!! :cheesy:

 

Next I'd like to be able to write things too, so I can send things from the windows machine to the linux box. As I said, the directory has wrx rights for everybody, so I assumed this would work - but from the windows box I just get "access denied" when I try to copy things or even just create a new text file. From the linux box normal users can create and copy files no problem.

 

I went into the properties of the share, and set them to public:yes, writeable:yes, browseable:yes. I wasn't sure about the user options bit but put the single username in the "write list" box anyway. Even after a samba server restart, the windows box still can't create a text file in that directory...

 

Any idea what might be the final missing piece???

Link to comment
Share on other sites

I would set security to standard and temporarily turn off the firewall then test.

If it then works, start the firewall again and test. Keep hardening your system until you break the share, then you'll know were to start tweaking things.

 

Ken

Link to comment
Share on other sites

I would set security to standard and temporarily turn off the firewall then test.

I did both those things (security is now standard, and the firewall is off), and restarted the samba server, and rebooted the windows machine, but still only read access.

I read that remote machines connect as the user "nobody", so I used this as the only username in the samba config, added it to the write list, and made sure the share properties were still public:yes, writeable:yes, browseable:yes but still the windows box can only read files, not write / rename / copy / create files.

Link to comment
Share on other sites

You have to set the access rights to the share within samba to who can read/write, etc. That should normally do the trick. If you did that, then you can ignore me :)

 

Who owns the folder that you create on the Linux system? Maybe try:

 

chown -R nobody:root /usr/sambafolder

 

normally though, /usr is for programs, and data would go in /var. But if you're space is in /usr and nowhere else, then this is OK. Maybe also do:

 

chmod 660 /usr/sambafolder

 

If none of that works, then chances are the user is connecting as it's own user, and not nobody. Consider using:

 

smbpasswd -a username

 

and make sure the username is the same as the one being used on the Windows machine, and set the same password perhaps. And try again.

Link to comment
Share on other sites

chown -R nobody:root /usr/sambafolder

chmod 660 /usr/sambafolder

Did you read the bit where I said "I created a new directory under /usr/ and gave everybody wrx rights." ? ;) The directory belongs to root:root but everybody has wrx rights. And normal users of the linux box can copy files to this directory.

 

If none of that works, then chances are the user is connecting as it's own user, and not nobody.
Don't think so. When I map a drive from the windows box it asks for username / password combo, and I enter "nobody" and the password I entered in the samba configuration. If the password doesn't match, I don't even get read access, so I'm pretty sure it's connecting as nobody. The linux box has no username called nobody though, that's something that only samba knows about. I'm assuming I don't have to create a user on the linux box called nobody, do I?

 

smbpasswd -a username
Tried that, made no difference.
Link to comment
Share on other sites

Well, I just made a config, and had the same problem. I set my share as follows:

 

# Samba config file created using SWAT
# from 172.27.27.30 (172.27.27.30)
# Date: 2008/10/07 08:51:37

[global]
workgroup = CPC
netbios name = SAMBA
server string = Samba Server Version %v
passdb backend = tdbsam
cups options = raw

[homes]
comment = Home Directories
read only = No
browseable = No

[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
browseable = No

[documents]
comment = Documents share
path = /samba/documents
read only = No
guest ok = Yes

 

I'm using the documents share. I had problems trying to save to it, and by default no username was required from my laptop (Gnome) and I still couldn't write to the directory. I then did:

 

chmod -R 777 /samba

 

and I could then read/write to the directory. So I figured that world read/write/execute might not be a good thing. So I now did:

 

chmod -R 755 /samba

 

which is how it was by default on my system when the directories were created. I then did:

 

chown -R nobody:nobody /samba

 

and now I have read/write access to documents share without the world read/write privileges that I set when testing originally. This worked for me.

Link to comment
Share on other sites

Yes, a package install would have probably created it. With yours it seems the user exists, just the group doesn't. So:

 

chown nobody:root -R /usr/sambashare

 

should do the job. Alternatively, do:

 

groupadd nobody

 

and then do:

 

gpasswd -a nobody nobody

 

will add user nobody to the nobody group also. And then repeat my chown again so that both user/group nobody are controlling the directory.

Link to comment
Share on other sites

Yes, a package install would have probably created it. With yours it seems the user exists, just the group doesn't. So:

chown nobody:root -R /usr/sambashare

should do the job.

Heh, you're right, the user already exists. I thought I didn't want to create the user cos then it would appear in the login list, which would be ugly. But sure enough, you're absolutely right and that chown nobody:root did the trick. Now the windows machine can write properly.

 

Weird though, don't you think? If everybody can wrx then why should it matter which user the directory belongs to??

 

Anyway, problem solved, thanks for your help, Ian!

:thumbs:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...