User Tools

Site Tools


eduardo:linux:smb

Samba Filesystem

  • Install 'smbfs' & 'smbclient' (Samba File System & Samba client)
sudo apt-get install smbfs smbclient
  • Create a mount point
mkdir /var/ftproot
  • Test the mount
sudo smbmount //192.168.1.2/Music /home/dbott/music -o username=dbott,password=mysecretpassword,uid=1000,mask=000
  • Umount
sudo smbumount /home/dbott/music
  • Add mount to fstab

The unsafe way (fstab is world-readable, meaning that anyone can see your SMB username and password):

//192.168.1.2/Music /home/dbott/music   smbfs  auto,username=dbott,password=mysecretpassword,uid=1000,umask=000,user   0 0

The better way (storing your username & password in a file only readable by root):

//192.168.1.2/Music /home/dbott/music   smbfs  auto,credentials=/root/.credentials,uid=1000,umask=000,user   0 0
  • /root/.credentials is a text file that contains your smb username and password. To create the file, type:
sudo gedit /root/.credentials
  • and add the following text:
username=your_smb_username
password=your_smb_password
  • Now, make the file only readable by root:
sudo chmod 600 /root/.credentials
  • At this point, you can either reboot or reload your fstab:
sudo shutdown -r now
sudo mount -a

Debug

  • Generate a list of available shares (replace 192.168.1.2 with the IP or name of your SMB server):
dbott@thedrake:~$ smbclient -L 192.168.1.2 -U%

        Sharename       Type      Comment
        ---------       ----      -------
        PUBLIC          Disk
        Data            Disk
        Archive         Disk
        Music           Disk
        IPC$            IPC

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------
eduardo/linux/smb.txt · Last modified: 2024/02/23 08:20 by 127.0.0.1