Here’s the requirement: you want to work on your Linux (Ubuntu, in my case) desktop, but your data lives on an OSX / Mac machine. You need to share your folder from Mac, and connect to it from Linux.
How do you do that?
Well, there is likely more than one way to do this. But here’s a way that is working for me.
I’m going to assume you have a user account on your Mac machine that you will use when connecting. In my case this is not my regular Macbook user, but a new user I created for the purposes of a specific project. That way my own personal data doesn’t mingle with any of their stuff.
You should be able to log in with this user on your Macbook. It doesn’t need to be an admin user, but you will need an admin user (or their credentials) to do some of these setup steps.
I will be sharing out my
~/Development directory from my Mac. This is my home / user’s own directory.
Another way of writing this, which spells it out more clearly, is:
Setting Up Your OSX Folder Share
Start by heading to System Settings…
From there, select General on the left, and then toggle the File Sharing option to on / enabled.
Then click the
(i) next to the File Sharing toggle. That’s pretty unintuitive UI for OSX, but that’s what needs to be done.
If you are logged in as your machine’s admin user, you may not see a prompt.
However, I am logged in as a none admin user, so I am required to enter some valid admin credentials:
From there I can select one or more folders that I would like to share.
+ icon to pick a folder. You can pick a sub-folder, or a top level folder.
I pick my user’s
From there I need to choose which Mac users have what permissions to that folder.
I pick my own personal user and my current user to have Read & Write permissions.
You only really need to make sure you give Read & Write to whichever user you will be using when connecting to this share.
Very important, and easy to miss, click the Options… button (above) and then ensure that Share files and folders using SMB is ticked, and it is On for whichever users will be connecting.
I have whited out my username as it gives away too much info for this post.
Click Done, and you can close down all them menus now.
From the OSX side, we are finished.
Connecting To Your OSX Folder Share From Linux
Everything from here on in will be done via Linux command line.
Open up a new terminal and change to your home directory, if you are not already there:
cd ~Code language: Shell Session (shell)
Now you need to create a new file that will contain your remote / OSX user credentials.
I will create the file named
.osxsmb-remote-user-credentials but you can call this what you like.
chmod 600 on that new file to ensure only my current user has any access to the credentials. This is because they will be stored in plain text. Security nightmare.
touch /home/chris/.osxsmb-remote-user-credentials chmod 600 /home/chris/.osxsmb-remote-user-credentialsCode language: Shell Session (shell)
You may be wondering why we need to do things using plain text. I certainly was. This Stack Overflow post explains why. I have tried using
sshfs for this very process, and I have found my JetBrains IDE’s do not like this approach at all.
When providing your remote connection details you will need the obvious two: username, and password.
You will also need to know your Mac’s domain.
In my case, this is
You may not be on the
To find this out, open a new terminal and type in:
cat /etc/resolv.confCode language: Shell Session (shell)
This should spit out something like:
lots of info about what this file is about search Home nameserver 192.x168.0.1 namserver fe8d:d1ce:a912:blah:blah:blahCode language: Shell Session (shell)
The line you care about is
search Home. Whatever comes after
search is very likely your domain.
Now open the file:
vim /home/chris/.osxsmb-remote-user-credentialsCode language: Shell Session (shell)
and add the following contents:
username=your-remote-osx-username domain=Home password=your-remote-osx-passwordCode language: Shell Session (shell)
Save the file.
vim that would be pressing esc followed by typing :wq and pressing return.
OK, that’s our credentials done.
Next, we need to create a mount point.
For this I use the
cd /mntCode language: Shell Session (shell)
From here, you need to create a new directory. This directory should be empty, as I believe you can use an existing directory but the mount will ‘overwrite’ the contents until the unmount command happens.
Basically just create a new directory unless you know way more than I do, in which case why do you even need to read this tutorial?
mkdir my-osx-mounted-folderCode language: Shell Session (shell)
Now you are ready to mount the remote OSX folder on to your Linux machine.
Here’s the command I use:
sudo mount.cifs //192.168.0.26/Development /mnt/my-osx-mounted-folder -o nounix,sec=ntlmssp,noperm,rw,credentials=/home/chris/.remote-osx-credentials,uid=$(id -u),gid=$(id -g)Code language: Shell Session (shell)
I appreciate that is not the easiest thing to read. Here is a slightly more readable version:
sudo mount.cifs //192.168.0.26/Development \ /mnt/my-osx-mounted-folder \ -o nounix,sec=ntlmssp,noperm,rw,credentials=/home/chris/.remote-osx-credentials,uid=$(id -u),gid=$(id -g)Code language: Shell Session (shell)
This command is used to mount a network share from a remote machine to a local folder on your Linux machine. The command uses the “mount.cifs” command, which is used to mount a CIFS (Common Internet File System) share.
Here is a breakdown of the different parts of the command:
sudo: This is used to run the command with root privileges, which is required for mounting network shares.
mount.cifs: This is the command used to mount the CIFS share.
//192.168.0.26/Development: This is the path to the remote share that you want to mount. The IP address (192.168.0.26) is the address of the remote machine, and “Development” is the name of the shared folder on that machine.
/mnt/my-osx-mounted-folder: This is the local folder where you want to mount the remote share. This folder should already exist on your Linux machine.
-o: This is used to specify options for the mount.
nounix: This option disables the use of Unix extensions for the mounted file system.
sec=ntlmssp: This option specifies the security mode to use for the mount. In this case, it uses the “
ntlmssp” security mode.
noperm: This option disables permission checks on the file system being mounted.
rw: This option mounts the file system as read-write.
credentials=/home/chris/.remote-osx-credentials: This option specifies the path to the credentials file that will be used to authenticate with the remote machine. The file should contain the username and password for the remote machine.
uid=$(id -u): This option sets the UID (user ID) of the mounted file system to the UID of the current user. This ensures that the current user has permission to access the mounted folder.
gid=$(id -g): This option sets the GID (group ID) of the mounted file system to the GID of the current user. This ensures that the current user’s group has permission to access the mounted folder.
If that command runs successfully, you should now be able to change directory into that new mount point and see the contents of your remote folder.
You should also have the ability / permission to create, read, update, and delete files and folders on your remote share.
If, however you see something like:
mount error(13): Permission denied Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)Code language: Shell Session (shell)
Then run the command it is telling you:
dmesgCode language: Shell Session (shell)
That command will spit out a lot of stuff, though it should be the very last few lines that are helpful:
From there you can better understand what went wrong. Most likely it’s a username or password issue.