12

I want to mount an external drive, connected on computer A, to computer B.

I am able to access and mount the drive by connecting to the server through Finder (Command-K), but how can I do this exact action through the terminal? I've been using several formats of mount and mount_afp but nothing seems to work. Something along the lines of:

mount_afp -i afp://user:pass@ipaddress/Volumes/SharedDrive /Volumes/Shared

In Finder, I just type the IP of the Mac connected to the drive, input credentials, and mount the selected drive...but it's not working by simply entering the afp://ipaddress, just like the 'Connect Server' command through Finder, in the terminal.

How do I do the same connection with a bash command? The end result will be the mounted drive on B.

  • Which error messages are you getting? – nohillside Oct 28 '13 at 17:25
12

A couple of things you need to be aware of.

First - the AFP URL needs to contain the name of the share - not it's location on the server. Second, the mount point must be an empty directory that you have write permission to. So your commands might be :-

sudo mkdir /Volumes/mount
sudo mount -t afp afp://user:pass@ipaddress/SharedDrive /Volumes/mount
  • Eek! What if I don't want to store my afp use/pass in a bash script because...well...if one computer is compromised, why give the keys away to another. Plus, that has to be bad practice, right? I guess I'll test if I can be prompted for the user/pass by the script instead. – keyboardSmasher Nov 9 '18 at 18:05
  • Sure, if you're scripting at the user level then you can prompt for the password and stored it in the variable pass. Then replace "pass" with ${pass}. – Tony Williams Nov 11 '18 at 3:56
  • Yep that makes sense. I was hoping that somehow a call to afp could trigger the user to enter the password, but I guess doing it manually is just as good. Thanks for the reply. :) – keyboardSmasher Nov 12 '18 at 5:37
1

Try:

sudo mount -t afp afp://user:pass@ipaddress/user /Volumes/Shared
-2

See https://apple.stackexchange.com/a/171822/154516 and comments for:

open smb://<user>:<password>@server/<Volume>
  • So smb is the acronym for Sapple Miling Brotocol? – klanomath Dec 28 '17 at 16:49
  • Works the same way with Apple Filing Protocol, of course. The answer is just a quote from the linked page. And it's the only valid answer to "how can I do this exact action through the terminal?". mount needs a mount point, so it's not the exact same action. – Gerrit Griebel Jan 12 '18 at 21:05

You must log in to answer this question.

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