There are a wide vareity of tools available under Linux that will connect to a Samba share, most of which don't actually mount the share, instead connecting over the smb protocol (you have probabably seen "smb://" in the address bar of Nautilus or Konquerer at some point; that's why). I could have tried something like that but actually mounting the drive seemed like the way to go on Crunchbang, since that way any file manager would be able to browse it, and the Samba mounting utilities have been part of Linux forever, so they should work pretty well under any distro, right? I've used "mount -t smbfs", "mount -t cifs", "mount.smb", "mount.cifs" in other distros with no problems, but for some reason on Crunchbang each time I got various error messages that I didn't record.
I spent several days Googling and trying out various alternative options like fusesmb, smbnetfs, and gigolo. Fusesmb and smbnetfs are supposed to be userspace apps where you give it a directory and it sets up all of the shares on your local network inside that directory. It seemed great; I didn't even need root permissions! Filled with hope, I ran "smbnetfs ~/network" and then browsed into the "network" folder, only to find my wife's Windows laptop listed but not the Samba share I'm trying to get to. It was insanely frustrating and I almost gave up and went back to Ubuntu.
To make a long story short, I eventually got it working in 3 steps:
- I installed smbfs, which is not included in Crunchbang by default, by running "sudo apt-get install smbfs"
- I created a new directory to mount my samba share by running "mkdir ~/smbshare"
- I mounted the share inside the new directory by running "sudo mount.cifs //ServerIPAddress/jizldrangs ~/smbshare -o username=jizldrangs, password=mypassword".
I only needed to do this once, so it worked out just fine for me, but if you have to do this a lot, or want to script it and don't feel comfortable storing your password in a script, you can also do the following:
- Create a new text file containing the username and password in the format specified above except on separate lines (i.e. put "username=yourUserName" on the first line and "password=yourPassword" on the second line).
- Save it somewhere out-of-the-way.
- Change the owner to root by running, "sudo chown root /path-to-file/file-name"
- Remove all permissions except read and write by the owner (which we just set to root) by running "sudo chmod 600 /path-to-file/file-name". This will ensure that only the root user can read the file containing your credentials.
- Modify the mount command above to, "sudo mount.cifs //ServerIPAddresss/share-name /path-to-mount-directory/mount-directory-name -o credentials=/path-to-file/file-name"