5

I want to mount a shared directory on my mac into a folder on my Ubuntu server so that I can copy backup files to the mac using some sort of automation.

Before I even start on the whole automation thing I would like to be able to mount the directory manually.

Oh how I have Googled! I have come up with many versions the mount command. The one that came closest to working (that is, it asked for my password and didn't object to the answer) was this:

sudo mount -o user=**** //192.168.1.4/server_backups /files/mountpoint

It produced the following error:

mount error(95): Operation not supported

Am I on the right track? I have tried various versions of the command. Either it fails on authentication or I get the above error.

Any help or advice would be greatly appreciated,

thanks,

Simon.

3

4 Answers 4

7

How to mount SSH locations using SSHFS.

Step 1:

  • "On your Mac, open Sharing preferences if it isn’t already open, then select Remote Login. Selecting Remote Login also enables the secure FTP (sftp) service."

Step 2:

  • From Ubuntu, install SSHFS sudo apt-get install sshfs.
  • Make a mount point. #mkdir /mnt/macMount
  • Mount the SSH Folder #sshfs [email protected]:/ /mnt/macMount/
  • Then check to see it worked. cd /mnt/macMount and ls to confirm things are where they should be
1
  • Thanks amanthethy ... I will try this one in the morning.
    – Simon
    Jul 30, 2014 at 17:33
2

A shared folder is not the great way if you want to automate backups to your Mac

Instead enable SSH on the Mac on and transfer your backups over it.

Go into System Preferences’. Under ‘Internet & Networking’ there is a ‘Sharing’ icon. Run that. In the list that appears, check the ‘Remote Login.

Since you want to use automation. this will serve quite good.

Here is an example of how copy a folder from your Ubuntu computer to your mac

rsync -azvr /path/to/source/folder MAC:/path/to/where/you/want/to/saveit/

where MAC is the ip address of your mac the good thing with rsync that if you re-run this command it will only copy the changed files from the source directory over to your mac saving time and bandwidth.

the z flag adds compression. If you are copying a lot of already compressed files like movies, images or mp3s you don't gain any speed in using it

If you still want some kind of drive mapping so you can browse the computer from GUI. It can also be done over ssh with the help of sshfs

on your Ubuntu computer install sshfs. Then add your user to the fuse group and finally mount the remote server

from terminal:

sudo apt-get install sshfs # install sshfs
mkdir macfolder 
sshfs username@MAC:/ macfolder

will mount your mac root filesystem under the folder macfolder

3
  • Thanks for that tomodachi - I like the look of this solution, I shall be trying it in the morning. I still want to acheive the drive mapping, the solution above looks good but this solution looks just right for backup purposes.
    – Simon
    Jul 30, 2014 at 17:35
  • @Simon added instruction for mounting the folder over ssh as well
    – tomodachi
    Jul 30, 2014 at 18:48
  • Yes, that all worked thank you tomodachi. rsync is definately the solution for me regarding the backups. The sshfs solution will be most useful for other purposes. rsync has given me another problem but I think i should open a new thread for it.
    – Simon
    Jul 31, 2014 at 9:19
1

Aside from being the best way or not, this finally worked for me, connecting to a OS X 10.9.5 share from Ubuntu 14.04, after much blood, sweat, tears, and googling:

sudo mount -t cifs //192.168.0.101/ShareName /media/localsharedir -o noauto,user,credentials=/home/myself/.smb-credentials,noperm,uid=myself,gid=myself,sec=ntlmssp,nounix

I leave it here for anyone else having trouble mounting a share served by OS X.

I'm not sure if all the -o options are required or not; from what I've read, only sec=ntlmssp,nounix are necessary, but those alone did not work by themselves for me.

I had to create /media/localsharedir and set ownership to myself.

My .smb-credentials file only contains:

username=my_os_x_username
password=my_os_x_password

with no workgroup/domain specified.

Good luck out there.

1

Dale Anderson's answer worked for me on Ubuntu 16.04 connecting to macOS 10.12.6 (Sierra).

I had been looking for a way to do this for quite some time, without success. I thought it was not possible, maybe because macOS had been updated to somehow exclude Linux, or that it would require manually hacking macOS (I have seen a few answers mentionning this).

It turns out that it was not straightforward but not impossible either, and Dale had the answer.

It would like to add that you do not need the Mac's IP address, and that you don't have to store your macOS username and password in a local text file, which I think is risky. You can use this command, which contains the Mac's machine name and the macOS username, and that will prompt you for the user's password:

sudo mount -t cifs //MacBook-CT.local/Projects mnt/projectsmac -o noauto,user,username=christopher,noperm,uid=ct,gid=ct,sec=ntlmssp,nounix

Please note that I use a mount directory located inside my own home directory, so mnt/projectsmac is not a typo (I have a projectsmac directory inside a mnt directory under my home dir).

"christopher" is the macOS username, and "ct" is the Ubuntu username.

Also, the Mac's machine name is a potential source of problem. My Mac's name is actually "MacBook_CT", but I can't use it in the Linux command. To find out the name you must use over the network, open Sharing preferences on your Mac.

You can go even further and put the Mac user's password directly in the mount command:

sudo mount -t cifs //MacBook-CT.local/Projects mnt/projectsmac -o noauto,user,username=christopher,password="12345678",noperm,uid=ct,gid=ct,sec=ntlmssp,nounix

This may be practical if you want to embed this command in a script.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .