To map a remote samba share in Linux with read-write access and a username and password, you will require samba. In debian based distros, this is easily obtained via sudo apt-get install samba
.
- Create a secure credentials file:
[email protected]:~$ cd /root [email protected]:/root$ su Password: [email protected]:~# echo username=username > .smbpasswd [email protected]:~# echo password=password >> .smbpasswd [email protected]:~# cat .smbpasswd username=username password=password
- Now you want to protect this file so that only root can read it:
[email protected]:~# chmod 400 .smbpasswd [email protected]:~# ls -al .smbpasswd -r-------- 1 root root 36 2009-07-21 00:24 .smbpasswd [email protected]:~#
- Open /etc/fstab in a text editor (make sure you’re root still!)
roo[email protected]:~# cd /etc [email protected]:/etc# joe fstab
- Add a similar line to the end of the file (don’t forget to leave blank line at the bottom!)
//serverip/sharename /mnt/path/filedrive smbfs credentials=/root/.smbpasswd 0 0
- Now just tell the system to mount all points defined in fstab:
[email protected]:/etc# mount -a
That’s it, you should now have your drive available!