Linux: Mount remote Windows shares with smbfs

It’s actually quite easy!

In Debian you will have to install smbfs. Some distros install this package by default. First create a mount point to which we will refer to as /mountpoint from this point forward.
mkdir /mnt/mountpoint

To mount:
mount -t smbfs -o username=<username>,password=<password>,workgroup=<workgroup/domain> //servername/share /mountpoint
If you don’t want to type your password in the comman then don’t. Remove password=<password> and you will be asked to enter it once you hit enter. To use local credentials use the server name in <workgroup/domain> and to use domain credentials use the domain name. Username must match the domain or server you are authenticating against.

You can also mount admin shares. Instead of //servername/share use //servername/<driveletter>$

You can ultimately auto mount remote shares during boot by adding those lines to your fstab, but if your Linux box is not a member of the domain and can’t authenticate mount process will fail unless you have smbfs authenticate automatically. This is not the safest way of auto mounting shares in Linux as you are going to store your password in a text file. As precaution you can make the file accessible to root only.

To do so, add this line to your fstab:
//servername/sharename /mountpoint smbfs auto,credentials=/root/.passfile,uid=1000,umask=000,user 0 0
/root/.passfile is where you will store your network passwords. Create it and add the credentials:
nano /root/.passfile

Then add the following lines:
username=<username>
password=<password>

To make the file readable by root only:
chmod 600 /root/.passfile

Once you’re done with all this, go ahead and mount the shares:
mount -a

Remote share will be mounted automatically after every reboot.

Linux: A simple and quick way of sharing a folder with Windows systems using Samba

Here is the quickest way to share a folder with read/write access.

Get rid of all lines in your /etc/samba/smb.conf and replace them with:

[global]
workgroup = workgroup or domain
server string = %h server
security = user
obey pam restrictions = Yes
passdb backend = tdbsam
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n *password\supdated\ssuccessfully* .
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
panic action = /usr/share/samba/panic-action %d
encrypt passwords = yes
invalid users = root

[Share name]
path = /home/share/
comment = comment
public = yes
browseable = yes
writeable = yes
valid users = user who will access the share
create mask = 0755

Restart your samba server:
/etc/init.d/samba restart

You must have an smb account for specified user. To create one:
smbuser <username>
smbpasswd <username>

Enter password for user.