Wednesday, March 26, 2008

Mount a Windows share from Ubuntu

How to mount a windows share from ubuntu

# Install smbfs
sudo apt-get install smbfs

# get the UID of the single user, this will be used in editing /etc/fstab
grep $username /etc/passwd | cut -d: -f3
# NOTE $username = the real users login name

# create a file under /home/$username/ named ".smbcredentials" with the following text
username=MyUsername (username could also be username@domain)
password=MyPassword

# protect the .smbcredentials file, because your password is in plain text
sudo chown root .smbcredentials
sudo chmod 600 .smbcredentials

# backup the /etc/fstab
sudo cp /etc/fstab /home/username/backups/

# edit fstab (I used cifs). Make sure its all on 1 line. use the uid you got earlier
//servername/sharename /path/to/mnt cifs credentials=/path/to/.smbcredentials,uid=1000 0 0

# reload fstab
sudo mount -a

No comments: