If I use Finder's ⌘K shortcut, I can mount SMB shares as my normal MacOS user. A mount point is created in /Volumes, and the mount point will be owned by the user I'm logged in as.
But there are limitations to this approach. One limitation is that Finder will only let you use one account on the remote system. In other words, If I have access to two home directories under different accounts on the same SMB server, I can't mount them both with Finder.
But I can mount them both from the command line. The command is:
mount -t smbfs //user@host/target mount-point
Apparently, on older versions of MacOS you would just run this command as your normal user and the resulting mount would be owned by that user. Someone claims success doing this here.
Someone else had the same problem as me, but with a different error, here. The solutions provided then don't work now.
On my MacOS 10.15.7 system, you can't run the
mount command unless you're root. The error you get if you run without root depends on if the mount point exists or not.
If it does:
macbook:~ user$ mount -t smbfs //user@host/remote-path local-path Password for host: mount_smbfs: mount error: /Users/user/local-path: File exists mount: /Users/user/local-path failed with 64
If it doesn't:
macbook:~ user$ rmdir local-path macbook:~ user$ mount -t smbfs //user@host/remote-path local-path mount: realpath /Users/user/local-path: No such file or directory
File exists error is not caused by the SMB share already being mounted.
If I run the command as root, then it succeeds if the mount-point exists, but the mount point is owned by root and only accessible by root.
The equivalent command on Linux accepts a
-o uid=<uid> option that controls which user will own the files. The man page for
mount_smbfs does not document any such option, and it doesn't accept the
-o uid option.
Is there a way to do what Finder does (make the mount point owned by
user) but from the command line?