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:
tim@ubuntu-server:~$ cd /root tim@ubuntu-server:/root$ su Password: root@ubuntu-server:~# echo username=username > .smbpasswd root@ubuntu-server:~# echo password=password >> .smbpasswd root@ubuntu-server:~# cat .smbpasswd username=username password=password
- Now you want to protect this file so that only root can read it:
root@ubuntu-server:~# chmod 400 .smbpasswd root@ubuntu-server:~# ls -al .smbpasswd -r-------- 1 root root 36 2009-07-21 00:24 .smbpasswd root@ubuntu-server:~#
- Open /etc/fstab in a text editor (make sure you’re root still!)
root@ubuntu-server:~# cd /etc root@ubuntu-server:/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:
root@ubuntu-server:/etc# mount -a
That’s it, you should now have your drive available!