PDA

View Full Version : Samba Tutorial (FC2)


rendered_one
26th May 2004, 06:17 AM
This is a tutorial for using SAMBA to connect to your Win9x/2000/XP (and whatever other vers of windows there are) shares. You will need root access.

First open up a terminal (as reg. user) and type:
"smbclient -v"
smbclient should print some version information.
If it does, great, if not, make sure you have samba installed!!!

First of all to display the machine's shares you need to know the machines name. In my case it is "serv1". To view the machines shares type this in:
"smbclient -U userid -L machine "
Where you replace 'userid' and 'machine' with your NETWORK username and the name of the machine you are trying to connect to. In my case this is tim and serv1.

It will prompt you for a password, type it in. After that it should list all the machines shares.

Now type this in:
"su -"
This should promt you for the root password, type it in.

cd to /etc/samba

Now create a file called "auth.smb" (it doesn't have to be this, i've done it for clarity). Using your favorite text editor put the following lines in the file:
"username = netuserid
password = netpass "
Replacing netuserid and netpass with your username and password respectivley.

If your unsure how to do this, type:
"vi auth.smb"
At the command prompt. When it appears, press the Insert key on your keyboard and type in the above (MAKE SURE YOU PUT THEM ON TWO SEPERATE LINES). When your finished press the Esc key on your keyboard, type press : (thats the colon key), and then type "wq" and enter.

Next you need to make sure that no-one else can access the file by typing:
"chmod 600 auth.smb"
This changes the file permissions to "-rw-------", meaning that only root can read or write to the file.

Before you mount your share, you will need to create a dir for it. Type:
"mkdir /mnt/sharename "
At the command prompt. Where sharename is the name of your share (for clarity only, you can name it whatever you want).

Now type this at the command prompt:
"smbmount //machine/share /mnt/sharename -o "credentials=/etc/samba/auth.smb,uid=userid,gid=userid,fmask=664,dmask=775"
Where machine, share, sharename, and userid are replaced with their respected values. In my case where I am connecting to win98 on serv1 using my windows username tim and mounting it to /mnt/win98, I would type:
"smbmount //serv1/win98 /mnt/win98 -o "credentials=/etc/samba/auth.smb,uid=tim,gid=tim,fmask=664,dmask775"

If all you wanted to know is how to mount a share you can stop now. If you're looking to make samba automatically mount the shares on boot or want to simplify the mounting process for next time, then keep reading

Do all of this as root:
1. "vi /etc/fstab"
2. Press the Insert key
4. Goto the end of the file
5. Enter this line at the end of fstab:
"//machine/share /mnt/sharename smbfs nosuid,nodev,noexec,credentials=/etc/samba/auth.smb,uid=username,gid=username,fmask=664,dmask =755 0 0"
6. Press the Esc key
7. Press the colon key
8. Type wq then press enter

Replace 'machine', 'share', 'sharename', 'username', and whatever else you customized (the dir to auth.smb for example) to what your settings reflect. For me it would look like this:
"//serv1/win98 /mnt/win98 smbfs nosuid,nodev,noexec,credentials=/mnt/samba/auth.smb,uid=tim,gid=tim,fmask=664,dmask=755 0 0"
If you don't want to mount automatically but want to be able to mount (as any user) easily put "users,noauto," in front of nosuid and you will be able to mount by typing "mount /mnt/win98" at the command prompt.

If you can't wait until next boot (for auto mounts) do this:
"cd /etc/rc.d/init.d"
"./netfs start"
A script will run and mount your samba share(s), and if your in Gnome will put icons on your desktop for you.

Enjoy! :D

If you have any questions just send a reply to this post and I'll answer back asap.

P.S. Some good resources are the samba man pages and documentation at http://www.samba.org/

dwayner
26th May 2004, 11:15 AM
Thanks, I'm a newbie to linux and Fedora, I have installed Fedora Core 2 have have it dual booting with XP, and wanted to be able to access my shares on a Windows 2003 server.. I have followed your excellent "how to" through, but get this problem

cli_negprot: SMB signing is mandatory and we have disabled it.
4918: protocol negotiation failed
SMB connection failed

I have read elsewhere that I should use CIFS client instead..... but I would appreciate any step by step guide anyone can provide to help with this..

Thanks in advance.

Dwayne

Ug
26th May 2004, 01:33 PM
Good.

rendered_one
26th May 2004, 06:48 PM
Here is the download link for CIFS,
http://us1.samba.org/samba/ftp/cifs-cvs/cifs-0.8.7a.tar.gz
This should help.

rendered_one
26th May 2004, 07:46 PM
Try my tutorial on CFIS in the howto section, if you are using 2.6x kernel you shouldn't need to rebuild anything.

kpawson
5th June 2004, 03:32 PM
This is a excellent article:D
I was having problems trying to connect to my Windows box.. Thanks for taking the time to write it.

Just one thing though, when I tried to modify the fstab your intructions had credentials=/mnt/samba/auth.smb
I had to change this to credentials=/etc/samba/auth.smb for it to work.

Thanks again

rendered_one
6th June 2004, 10:21 AM
Sorry, thanks for the typo correction tho.

yeehi
9th June 2004, 01:54 AM
How do i find out what my network username is?
I found out what my windows computer name is by looking in my windows computer in my network places. The local documents had the name of my windows computer written on it.

rendered_one
9th June 2004, 11:43 AM
You can ask your network administrator... whicherver username you use to connect to the network using windows should be you network username.

smackey
10th June 2004, 01:12 AM
Hi, I'm new to the forum and somewhat new to Linux. Though I'm not an admin, I am an enthusiast.

My question is, are you running a firewall on the samba server/box? I find that the windows xp machine can see the samba file shares if the firewall is down on the samba server, but sees nothing if the firewall is running. What ports have to be open for this to work?

TIA

micha
10th June 2004, 08:10 AM
Opening the ports from 137 to 139 (called NetBIOS) should be enough:
http://www.chaminade.org/MIS/Articles/FirewallPortSecurity.htm

--Micha

Harryc
10th June 2004, 01:28 PM
I tried this tutorial, and when I try to connect to the network share on a win2k machine I get "session setup failed: ERRDOS - ERRnoaccess (Access denied.)". I read on google about possibly needing to set -W domain too. How would I do that? I don't use domain but I do have a workgroup set on the win2k machine.

[root@localhost init.d]# smbclient -U harryc2 -L harryc2
Password:
Domain=[HARRYC2] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]

Sharename Type Comment
--------- ---- -------
IPC$ IPC Remote IPC
D$ Disk Default share
Extranet Disk
Dialer Disk
ADMIN$ Disk Remote Admin
C$ Disk Default share
Domain=[HARRYC2] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]

Server Comment
--------- -------

Workgroup Master
--------- -------

----

Edit; here is the smbmount command I used -

smbmount //harryc2/Dialer /mnt/harryc -o "credentials=/etc/samba/auth.smb,uid=harryc,gid=harryc,fmask=664,dmask=775

----

I did set up an smb.auth file.
The strange thing is that when I enter the smbmount command, console just hangs with no return code . I have to hit ctrl-c to get back to a prompt.

engwnbie
11th June 2004, 02:26 PM
rendered_one This is great, excellent how to.
If anyone is interested there are also great examples and how to on your fedora installation. FC1 is a bit different. FC2 in /usr/share/doc/samba-3.0.3/docs there are pdf files that explain how to samba network with other operating systems. Samba-Guide.pdf has different examples and how to implement.

ofergal
15th June 2004, 05:23 AM
Thanks this is good reading!
My network has a win2k domain controller (AD) and all the windows (XP,2000,2003) PCs are in the domain.
I went through several samba tutorials but could not get the security to let me through.
Only share access worked.

Do you have a good Fedora core 2 HowTo that will cover AD?

JpMaxMan
26th July 2004, 07:01 AM
Subject pretty much says it all. I have a SMBFS mount which works fine from command line if I issue a "mount -a" command my mount points are all available. However, they do not automatically appear on-boot. Entry is similar to:

//10.10.10.10/mountdrive /mnt/mountdir smbfs username=name%pass,dmask=777,fmask=777 0 0

As an FYI - this is Red Hat Enterprise linux 3, not Fedora.... still this is a comprehensive post on Samba mounts, so I thought you might be able to give me a helping hand.

Other piece of info I just checked is after the system has booted and the mount not showing up:

/etc/init.d/netfs restart

mounts it just fine. So, the conclusion then is 'by default' netfs is not set to run on boot?

So, I checked using chkconfig --list and both smb and netfs are set to load for runlevels 3, 4, & 5.... which should be fine...

still does not mount on boot and when I either run "mount -a" or the "netfs restart" it then mounts fine. I also notice that running "netfs restart" a second time says it is removing the SMB mount points - which it does not say the first time I run it.

Furthermore, if I run "netfs status" right after boot it does list the mount points as "configured" however, I can not list the contents of the mounts.

Any help would be appreciated --- sorry for the rambling nature of the email as was typing I thought to check other things.

Cheers!

-JP

dih
26th July 2004, 01:21 PM
THANKS!
I've been looking for a good Samba tutorial for ages, this was exactly what I needed

radu_prelipcean
28th July 2004, 10:07 PM
Hi! I have problems trying to connect to my WinXP machine. I followed exactlly this tutorial (the smbmount part) and the result is that I blocked my Linux machine. If I try smbumount I get a message like: "device or resource busy". Did you experienced something similar?

Prem0
31st July 2004, 12:45 AM
Im having a bit of problem when I initiate the step where you start the fstab mount. Here is what it looks like:

[root@localhost prem0]# mkdir /mnt/test
[root@localhost prem0]# smbmount //workbox/movies /mnt/test -o "credentials=/etc/samba/auth.smb,uid=prem0,gid=prem0,fmask=664,dmask=775"
[root@localhost prem0]# nano /etc/fstab
[root@localhost prem0]# cd /etc/rc.d/init.d
[root@localhost init.d]# ./netfs start
Mounting SMB filesystems: [ OK ]
Mounting other filesystems: mount: mount point does not exist
mount: mount point 0 does not exist
[FAILED]

Now after I do the smbmount I can go to /mnt/test and it works.

I am also including my fstab text

LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/hda3 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,$//workbox/movies /mnt/test smbfs
nosuid,nodev,noexec,credentials=/etc/samba/auth.smb,uid=prem0,gid=prem0,fmask=6$0 0

Can someone please tell me why this isnt working?

Ned
31st July 2004, 06:16 PM
Sorry, thanks for the typo correction tho.

May I suggest you edit your post to correct the typo - people may not read all the subsequent posts and spot this :)

Ned

verbose
5th August 2004, 04:47 AM
This is going to sound fairly stupid but, after having installed Fedora I'm confused as to what Samba's function is. I know basically what it does but the reason I'm confused now is because, by default (as in MDK 10), my Windows partition is not being shared, under /mnt/windows. I've just recently gotten my networked computer shared but I was under the impression, at first, Samba was for local share. I've edited lmhosts, smb.conf, smbusers with my Windows partition information but now the networked computer shows up under Network (GUI).

If I do smbclient //localhost/username I get "Error connecting to 192.168.0.1 (Connection refused)".

I figured out what exactly Samba was in either the manpage or htmldoc but I can't remember where. Does it function with both local and remote computers or what?

Confused...
Thanks

verbose
5th August 2004, 05:13 AM
When I type "smbmount //machine/share /mnt/sharename -o "credentials=/etc/samba/auth.smb,uid=userid,gid=userid,fmask=664,dmask=775" I receive the error:

tree connect failed: [..]

animal_freak3
6th August 2004, 01:54 AM
Thanks a bunch, rendered_one! This article helped a lot! I've been trying for the last several weeks to get hooked up to my windows box and was about ready to dump FC2 altogether and go back to my win98 until I stumbled across this article! the onyl problems I had were the same on as kpawson, (although I fixed it by making the aforementioned directory and copying the file to that directory) and I had to use the KWrite to edit fstab, because I kept getting some strange error using the "vi" command, and it wouldn't let me save the modification, but I managed to get it working! Thanks a bunch!

animal_freak3
6th August 2004, 01:57 AM
Hey, radu, do you have any kind of firewall on your windows box? You may have to make sure that your IP address is not blocked before you can connect to it.

nejc
20th August 2004, 01:12 PM
great tutorial, even for a linux newbie like me.

thanx for sharing it!

nitschkecm
24th August 2004, 06:03 PM
Hi,

first of all many thanks for this great tutorial. It really made my day to be able to use SAMBA.... I am experiencing a similar problem which was posted earlier. I believe it might be linked to the fact that I am using a wireless network. The mount function is called directly after the pcmcia card is being initiated for which I believe that the network on the fedora box is still not ready to make a tcp/ip connection. Is there a way to delay the mount of the SMB to a later point in the boot processs ? I would believe that this should do it since I can easily restart the netfs service.

Thanks

Carsten

Running Fedora Core 2

rendered_one
25th August 2004, 10:37 PM
Hey everyone on this thread, sorry I haven't been able to answer any questions.. my internet, as well as my FC2 installation have both been down latley. If an of your questions havent been resolved yet, please let me know and I'll do my best to help fix them. I know how annoying it is not to be able to access your files via networking. I can't count on two hands how many times I've swapped CD-RWs between computers when my network has been down.

Sincerely,
Rendered_One

nitschkecm
27th August 2004, 04:27 PM
Hello,

I just wanted to reply to rendered_one. My item with the boot problem persists as well as I have another question. What do I have to do in order to be able to write to a folder on windows machine from linux (i.e. how to I have to set the security on both machines).

On the other side if I want ot be able ot access a folder on my linux machine from a windows machine how do I do that ?

Thanks

greenleaf
4th September 2004, 08:15 PM
Dear rendered_one:

Thanks for the good info you posed.

My previous post here:
http://www.fedoraforum.org/forum/showpost.php?p=97898&postcount=1

And I found this:
http://www.fedoraforum.org/forum/showpost.php?p=15257&postcount=1

There are others:
http://www.fedoraforum.org/forum/showpost.php?p=95707&postcount=1

Think many people like myself have the same problem, and you info seems to be relevant.

I hope you can comment is this a FC2 bug, because someone pointed out kernel error was discovered with it. I don't understand because my method worked in other Linux. Hope to learn if from you about where am I wrong as well as other users here.

Point is to learn from mistake and understand the problem.

Regards

greenleaf
4th September 2004, 08:30 PM
Don't forget to leave people feedback to their posts! Just click on the scales icon next to the post.

To rate people's post where exactly is the icon? :confused:

dylpower
23rd September 2004, 07:52 PM
Thanks for the great turorial rendered_one!!

I can now see my laptop running XP with my FC2 box (I'm able to mount it automatically and go through the files). The only problem is that my printer is hooked up to the FC2 box and I would like to be able to print to it from the XP laptop. It appears that XP does not see the linux box. Not sure what to do...

rendered_one
23rd September 2004, 09:47 PM
Hey,

I'm not quite sure what kind of boot problem your having, but in response to the question about sharing, what you would have to do is goto your apps menu, then System Settings | Server Settings | Samba. From there you should be able to set user names and share folders on your linux machine to windows. I've tried this with a w2k server and professional and it works well in both. You can setting server settings by going to Preferences | Server Settings and set usernames and paswords by going to Preferences | Samba users. This should also work for dylpower's printing problem.

superbnerd
23rd September 2004, 09:52 PM
To rate people's post where exactly is the icon? :confused:
in the left hand sile there is a box labeled Reputation.

rendered_one
23rd September 2004, 09:55 PM
Thanks for the great turorial rendered_one!!

I can now see my laptop running XP with my FC2 box (I'm able to mount it automatically and go through the files). The only problem is that my printer is hooked up to the FC2 box and I would like to be able to print to it from the XP laptop. It appears that XP does not see the linux box. Not sure what to do...

Hey, in order to share folders and printers you first need to configure your samba settings, by going to your apps menu (K menu if in KDE and the big foot under GNOME) and clicking System Settings | Server Settings | Samba. From there you can set up usernames and passwords for accesing your shares much like wind0ze (except better ;)). Then you can share your printer via the Gnome Printer Configuration app under Systen Settings | Printing. Then click on your printer, click edit, and then click the sharing button at the bottom. If you don't have Samba in your Server Settings menu then you might not have it installed properly, try installing it off the cd and updating via yum. If you need anymore assitance let me know ;).

-RenderedOne

dylpower
24th September 2004, 03:57 AM
Thanks so much for all your help!
Well, I set up a public folder on my linux box to be read/write with acces for everyone. I tried to set up a username and password (my linux username and password). The funny thing is it doesn't show up when I go back into the menu. The only user listed is "nobody". I then set the printer to share. It seems that XP still can't see the shared folder or print. Any ideas?

Thanks again, I love Canadians.

superbnerd
24th September 2004, 04:32 AM
have you enabled wins support? in you smb.conf under /etc/samba make sure you have a line in your global section that says wins support= yes and a line like this name resolve order = wins lmhosts bcast and tell each windows computer the ip of you wins server (your samba server) in the advanced section of tcp/is setup of windows.

dylpower
29th September 2004, 07:06 PM
I am having trouble getting swat to run from my browser as root via http://localhost:901/
Here are the particulars:
/etc/services
swat 901/tcp

/etc/xinet.d/swat
service swat
{
port = 901
socket_type = stream
wait = no
only_from = localhost
#127.0.0.1 -this was in the file initially, i changed it to the above
groups = yes
user = root
server = /usr/sbin/swat
log_on_failure += USERID
disable = No
}

and swat is installed. When I try an connect I get "connection refused by localhost". Any ideas? I'm trying to set up users which the samba tool cannot do.

weber
8th October 2004, 02:32 AM
Rendered_One

I am having the same issue as JpMaxMan below. My smbfs mounts work great from the terminal command line but won't reconnect when I reboot; I just get a bunch of "tree connect failed" errors.

I'm running FC2 and connecting to WinXP. I'm using share level access control on both.

Any thoughts?

Thanks,
Weber

Subject pretty much says it all. I have a SMBFS mount which works fine from command line if I issue a "mount -a" command my mount points are all available. However, they do not automatically appear on-boot. Entry is similar to:

//10.10.10.10/mountdrive /mnt/mountdir smbfs username=name%pass,dmask=777,fmask=777 0 0

As an FYI - this is Red Hat Enterprise linux 3, not Fedora.... still this is a comprehensive post on Samba mounts, so I thought you might be able to give me a helping hand.

Other piece of info I just checked is after the system has booted and the mount not showing up:

/etc/init.d/netfs restart

mounts it just fine. So, the conclusion then is 'by default' netfs is not set to run on boot?

So, I checked using chkconfig --list and both smb and netfs are set to load for runlevels 3, 4, & 5.... which should be fine...

still does not mount on boot and when I either run "mount -a" or the "netfs restart" it then mounts fine. I also notice that running "netfs restart" a second time says it is removing the SMB mount points - which it does not say the first time I run it.

Furthermore, if I run "netfs status" right after boot it does list the mount points as "configured" however, I can not list the contents of the mounts.

Any help would be appreciated --- sorry for the rambling nature of the email as was typing I thought to check other things.

Cheers!

-JP

weber
8th October 2004, 12:33 PM
Further to my post above. I have noticed when I was looking at the log this morning that it is trying to mount the smb drives before it loads smbd and nmbd (see part of log file below). Could this be part or all of the problem? If so, how do I fix it.

Thanks,
Weber

[Boot.log]
...
Oct 8 07:02:37 localhost random: Initializing random number generator: succeeded
Oct 8 07:02:38 localhost rc: Starting pcmcia: succeeded
Oct 8 07:02:38 localhost mount: 1684: tree connect failed: ERRDOS - ERRnoaccess (Access denied.)
Oct 8 07:02:38 localhost mount: SMB connection failed
Oct 8 07:02:38 localhost mount: 1685: tree connect failed: ERRDOS - ERRnoaccess (Access denied.)
Oct 8 07:02:38 localhost mount: SMB connection failed
Oct 8 07:02:38 localhost mount: 1686: tree connect failed: ERRDOS - ERRnoaccess (Access denied.)
Oct 8 07:02:38 localhost mount: SMB connection failed
Oct 8 07:02:38 localhost mount: 1687: tree connect failed: ERRDOS - ERRnoaccess (Access denied.)
Oct 8 07:02:38 localhost mount: SMB connection failed
Oct 8 07:02:38 localhost netfs: Mounting SMB filesystems: failed
Oct 8 07:02:38 localhost netfs: Mounting other filesystems: succeeded
Oct 8 07:02:39 localhost apmd: apmd startup succeeded
Oct 8 07:02:39 localhost autofs: automount startup succeeded
...
Oct 8 07:02:48 localhost smb: smbd startup succeeded
Oct 8 07:02:48 localhost smb: nmbd startup succeeded

weber
9th October 2004, 03:42 PM
Ok, it seems that I have solved this problem with smb by trial and erorr. Here are the changes that I made to get smb shares to work on boot. I'm not sure which changes are actaully necessary but this is what I did and now it works.


Added the following lines to the [global] section of smb.conf:
wins support = yes
name resolve orrder = wins lmhosts hosts bcast
Added the following line to both '/etc/hosts' and '/etc/samba/lmhosts' to map the computer that I have the drives shared on (winbox) to it's IP address. This allowed me to use 'winbox' as the host name in fstab rather than the IP address.
192.168.1.10 winbox
Added the username option to the fstab lines. I know that this was a big part of the solution because I can turn it off and on. If I try to mount the share with the guest option it doesn't work. If I put in a username/pwd, it works. This is what my fstab lines look like now.
//winbox/mp3 /mnt/mp3 smbfs username=weber%"",ro 0 0


Hope this helps,
Weber

ieuuk
9th October 2004, 11:33 PM
i like - good job

promark
11th October 2004, 12:31 PM
Ok, it seems that I have solved this problem with smb by trial and erorr. Here are the changes that I made to get smb shares to work on boot. I'm not sure which changes are actaully necessary but this is what I did and now it works.


Added the following lines to the [global] section of smb.conf:
wins support = yes
name resolve orrder = wins lmhosts hosts bcast
Added the following line to both '/etc/hosts' and '/etc/samba/lmhosts' to map the computer that I have the drives shared on (winbox) to it's IP address. This allowed me to use 'winbox' as the host name in fstab rather than the IP address.
192.168.1.10 winbox
Added the username option to the fstab lines. I know that this was a big part of the solution because I can turn it off and on. If I try to mount the share with the guest option it doesn't work. If I put in a username/pwd, it works. This is what my fstab lines look like now.
//winbox/mp3 /mnt/mp3 smbfs username=weber%"",ro 0 0


Hope this helps,
Weber

Great tutorial rendered_one have been trying for ages to be able to share my xp box

Still cannot get the auto mount to work I added the line from your original post to fstab but no joy and also did changes suggested by weber above but still no good

can anyone help

thanks a lot

Have just had a look at my boot.log pasted below
Oct 11 12:29:51 localhost mount: [mntent]: line 10 in /etc/fstab is bad
Oct 11 12:29:51 localhost netfs: Mounting SMB filesystems: succeeded
Oct 11 12:29:51 localhost mount: [mntent]: line 10 in /etc/fstab is bad
Oct 11 12:29:51 localhost netfs: Mounting other filesystems: succeeded

Line 10 is the line I added as per weber's tip but also get the same error with the original all the syntax is correct, well i hope it is as copied exactly

promark
12th October 2004, 01:21 PM
Great tutorial rendered_one have been trying for ages to be able to share my xp box

Still cannot get the auto mount to work I added the line from your original post to fstab but no joy and also did changes suggested by weber above but still no good

can anyone help

thanks a lot

Have just had a look at my boot.log pasted below


Line 10 is the line I added as per weber's tip but also get the same error with the original all the syntax is correct, well i hope it is as copied exactly

Well think I may now have got to the bottom of the problem the errors were caused by my line in fstab which is now sorted, but still will not auto mount the error I get in boot.log is now network is unreachable which I think is being caused by smb having not yet started because it starts a few lines down in the log.

Is this the case or am I way off base on this

Any Comments?

Satun Travel Photos on Instagram - Tirukkoyilur Photos - Holstebro Travel Photos