smb Clients
Install and configure smb clients for various platforms.
2022-08-06 Raspbian bullseye, macOS 15.5
Examples are based upon:
stringybark
- smb server
- fred
- samba user known to samba server
- freds
- Private samba share for samba user fred
- everyones
- Public samba share accessible to all samba users, and fred in particular
linus
- User on machine running linux OS
mac
- User on machine running macOS OS
This assumes the clients all use protocol SMB3.11. Anything less is too terrifying for security to contemplate…
Windows 10/11 File Explorer
supports smb protocol natively. See How to connect to Linux Samba shares from Windows. In brief, for Windows 11 in File Explorer:
- Enter location //stringybark/freds in address bar;
- Enter username fred & password when prompted.
Windows 10 requires more steps than this.
macOS Finder
supports smb protocol natively. See How to connect your macOS device to an SMB share. In brief, in Finder:
- In application menubar, select Go > Connect to Server...
- In details popup, enter smb://stringybark/freds for server, then press Connect;
-
In login popup:
- choose Registered User
- enter Name as fred
- enter Password
- tick Remember this password in my keychain
then Finder opens a tab with share freds open – Done.
mac:~ ls /Volumes-
Observe that share
freds
was mounted on/Volumes/freds
by default. It is navigable via shell. -
The volume can be dragged from Finder GUI pane into
mac
's login items so that it is reconnected at each login.
macOS private mount
provides samba private share as a local user mount at
~/a_share
on-demand by the user.
- Verify share
freds
is mounted.
- Verify expected contents of
fred
's share are shown.
- Verify share
freds
is no longer mounted.
linux private mount
provides samba private share as a local user mount at
~/a_share
on-demand by the user.
/etc/fstab
append to end
//stringybark/fred /home/linus/a_share smb3 noauto,rw,user,credentials=/home/linus/.creds/fred@stringybark.smb,uid=linus,gid=linus,_netdev
-
Passwords are stored in clear text so perms on
~/.creds
must be tight.
~linus/.creds/fred@stringybark.smb
new file
username=fred password=fred's password
Now we can mount it whenever we like as a non-privileged user:
linus:~ mount ~/a_share # mount linus:~ ls ~/a_share- Verify expected contents of share freds are shown.
-
They will all have ownership
linus:linus
irrespective of the ownership in the native storage.
-
The personal share can be made available during login session by adding
the
mount
andumount
commands to the login/out scripts e.g. for bash there is.bash_login
and.bash_logout
. This is beyond scope of this document.
linux public mount
provides a samba share permanently for all local users.
It is managed by root
.
- everyones
- A public samba share that is accessible by all samba users.
- fred
-
The public share needs credentials (i.e. a valid samba user) for
access. In this example we use poor fred's credentials for
everyone. It would often be better to define a generic samba user
e.g.
somebody
. nobody
- Generic UNIX user to own the public mounted share.
sambashare
- UNIX group for local users permitted to access locally mounted samba shares.
/smb/everyones
- Mount point for public share everyones.
linus:~ sudo apt update linus:~ sudo apt install cifs-utils linus:~ sudo vi /etc/fstab
/etc/fstab
append to end of file
//stringybark/everyones /smb/everyones smb3 rw,credentials=/root/.creds/fred@stringybark.smb,uid=nobody,gid=sambashare,_netdev
-
Passwords are stored in clear text so perms on
~root/.creds
must be tight.
~root/.creds/fred@stringybark.smb
new file
username=fred password=fred's password
-
Logout and login again for
linus
to pick up group membership. -
Add required local users to
sambashare
group to give them access.
- Verify expected contents of everyones share are shown.
-
They will all have ownership
nobody:sambashare
. We actually have fred's perms inside the share.
This is left permanently mounted. It will also be automatically re-mounted on reboot.
linux smbclient
provides ftp-like shell
interface to enter commands to the
remote share.