Turns out that I need to add a local (client) UID to the mount line in FSTAB to make this work. I arrived at this via sheer brute force:
//192.168.0.5/storage /media/myname/TK-Public/ cifs guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 0 0
Answer from Kendor on askubuntu.comTurns out that I need to add a local (client) UID to the mount line in FSTAB to make this work. I arrived at this via sheer brute force:
//192.168.0.5/storage /media/myname/TK-Public/ cifs guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 0 0
You are almost there. Open FSTAB by using:
sudo nano /etc/fstab
In the last line ( or on of the last lines) place:
//192.168.0.5/storage /media/myname/TK-Public/ cifs username=YOURUSERNAME,password=YOURPASSWORD,iocharset=utf8,file_mode=0777,dir_mode=0777
*** (this is all one long line)
Ctrl-X to close, Y to save and Enter to seal the deal.
Now reboot by:
sudo reboot
And you should have full control of the network share on your Linux device!
Hi everyone. Got a feeling I'm missing something super simple, but can't work it out myself. I can mount my CIFS share via sudo mount.cifs commands, but not withut sudo, nor via fstab. The share is only being mounted for myself on the desktop - no other users, hence why it's mounting within my home folder..
Followed MountCifsFstab, and I'm running Ubuntu Mate 20.4 LTS. Server is running Xubuntu 20.04 LTS.
This works in terminal, but the mount is in root, and read-only for non-root users.
sudo mount.cifs -o username=user,password=pass //192.168.1.102/torrents /home/desktop/mounts/torrents
These commands don't work, even though it's setup in /etc/fstab:
mount.cifs -o username=user,password=pass //192.168.1.102/torrents /home/desktop/mounts/torrents
mount /home/desktop/mounts/torrents
sudo mount /home/desktop/mounts/torrents
In all of these cases (same command without sudo, or trying to mount with/without sudo from fstab), the error returned is mount error(2): No such file or directory. Obviously, the file/directory does exist and the credentials are fine, because the first command works.
Extract of my /etc/fstab (all other lines in my fstab are for local disks, and none of them refer to :
# <file system> <mount point> <type> <options> <dump> <pass> //192.168.1.2/torrents /home/desktop/mounts/torrents cifs noperm,user,username=user,password=pass 0 0
So what is my fstab missing that prevents me from using fstab to mount (preferably without sudo)? Thanks in advance.
Have you tried this? https://unix.stackexchange.com/questions/120677/can-not-use-mount-cifs-mount-error2-no-such-file-or-directory
You might want to try to add sec=ntlmssp to your options. My cifs shares (which are on a samba server, not windows) won't mount without it.
Also, putting username and password in fstab is not a very good idea, as fstab is world-readable. It's better to put them in a file (I called it .smbcredentials, in my home dir), like this:
username=<whateveryourusernameis>
password=<whateveryourpasswordis>
Then, you can point to it in fstab with credentials=/path/to/.smbcredentials
HTH. If not, do mount -a, and look in syslog for error messages and post them here.
Videos
Solved by putting a line in fstab:
//192.168.1.33/Public /mnt/nasPublic cifs username=username,password=password,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0
then
sudo mount -a
Hmmm, do you really want perm 777 on dir and files? You can specify your file and dir mode adn the uid and gid. To allow non-root mounting, try the "user" or "users" option for the mount (see man mount.cifs)
e.g.
//myNAS/nasmedia /media/nasmedia cifs noauto,users,_netdev,credentials=/etc/.smbcredentials,iocharset=utf8,uid=1000,gid=1002,file_mode=0774,dir_mode=0775 0 0
It's good practice to avoid putting passwords directly in /etc/fstab (which is normally world-readable). Instead, put them into a file, and reference the file like:
//w.x.y.z/Home$ /mnt/dir cifs credentials=/home/username/cifs.creds,sec=ntlmssp,file_mode=0700,dir_mode=0700
/home/username/cifs.creds is owned by a suitable user (either root, or a user that corresponds to the SMB user who owns the SMB share), and chmod og-rwx. It contains the credentials in the format
domain=A
username=B
password=C
A, B and C above must be literal - there's no shell-like parsing of quotes or backslashes.
When you type the mount command, the part password='C' is first handled by the shell and becomes password=C before it gets to the mount command. This is not done with fstab entries, so you must remove the single quotes. If your password contains special characters you can replace them by their octal code, in particular \040 for space.