Can't get mount_afp to work

Hi - I have written a small script to mount the disk of another iMac running Leopard. I can mount the disk no problem using the Finder "Connect to Server..." menu option but when I try doing this from a shell script I always get an error:

sh-3.2# ./mount.sh
/Volumes/bbb hd not mounted
/bin/mkdir "/Volumes/bbb hd"
total 16
drwxrwxrwt@ 6 root admin 204 3 Oct 12:44 .
drwxrwxr-t 37 root admin 1326 29 Sep 22:02 ..
drwx------ 13 mmm staff 918 3 Oct 07:25 aaa
drwxr-xr-x 2 root admin 68 3 Oct 12:44 bbb hd
lrwxr-xr-x 1 root admin 1 3 Oct 07:24 drago hd -> /
lrwxr-xr-x 1 mmm admin 15 3 Oct 07:24 iDisk -> /Volumes/aaa
/sbin/mount_afp "afp://root:xxx@xxx.xxx.xxx.xxx/bbb hd" "/Volumes/bbb hd"
mount_afp: AFPMountURL returned error 1, errno is 2
Refreshing Disk Arbitration ...

As you can see the mount point is there but no matter what I try I get this error 1.

Looking on the INternet I found a few postings, mainly to do with Apple TV, and I can confirm that everything is in place:

sh-3.2# ls -al /System/Library/Filesystems
total 24
drwxr-xr-x 19 root wheel 646 12 Sep 12:09 .
drwxr-xr-x 63 root wheel 2142 28 Sep 14:46 ..
-rw-r--r--@ 1 mmm staff 6148 6 Mar 2008 .DS_Store
drwxr-xr-x 7 root wheel 238 23 Jul 05:56 AppleShare
drwxr-xr-x 7 root wheel 238 23 Jul 05:39 URLMount
lrwxr-xr-x 1 root wheel 49 23 Jul 05:36 afpfs.fs -> /System/Library/Filesystems/AppleShare/afpfs.kext
drwxr-xr-x 6 root wheel 204 24 Sep 07:12 cd9660.fs
drwxr-xr-x 3 root wheel 102 10 Jun 03:41 cddafs.fs
drwxr-xr-x 5 root wheel 170 5 Mar 2008 ftp.fs
drwxr-xr-x 5 root wheel 170 23 Jul 05:36 hfs.fs
drwxr-xr-x 4 root wheel 136 10 Jun 03:43 msdos.fs
drwxr-xr-x 3 root wheel 102 29 Nov 2007 nfs.fs
drwxr-xr-x 4 root wheel 136 10 Jun 14:29 ntfs.fs
drwxr-xr-x@ 8 root wheel 272 12 Sep 12:09 retrospectcd.fs
drwxr-xr-x 3 root wheel 102 10 Jun 14:37 smbfs.fs
drwxr-xr-x 4 root wheel 136 10 Jun 04:42 udf.fs
drwxr-xr-x 4 root wheel 136 7 Mar 2008 ufs.fs
drwxr-xr-x 4 root wheel 136 10 Jun 14:35 webdav.fs
drwxr-xr-x 4 root wheel 136 10 Jun 16:17 zfs.fs
sh-3.2# ls -al /System/Library/Filesystems/AppleShare
total 160
drwxr-xr-x 7 root wheel 238 23 Jul 05:56 .
drwxr-xr-x 19 root wheel 646 12 Sep 12:09 ..
-rwsr-xr-x 1 root wheel 38704 5 Mar 2008 afpLoad
drwxr-xr-x 3 root wheel 102 10 Jun 03:43 afpfs.kext
drwxr-xr-x 3 root wheel 102 10 Jun 04:49 asp_tcp.kext
drwxr-xr-x 3 root wheel 102 23 Jul 05:56 check_afp.app
-rwxr-xr-x 1 root wheel 38144 5 Mar 2008 sshHelper
sh-3.2# ls -al /sbin/mount_afp
-r-xr-xr-x 1 root wheel 46928 5 Mar 2008 /sbin/mount_afp

I just don't know what's wrong.

Any suggestions welcome.

Cheers
Michael

iMac 2.8 GHz Core 2 Duo, 4GB RAM, ATI Radeon HD 2600 Pro, Mac OS X (10.5.5)

Posted on Oct 3, 2008 5:02 AM

Reply
5 replies

Oct 3, 2008 11:07 AM in response to michaelw

I continued my investigation and noticed that I was getting the same "error 1" message when the remote computer wasn't even switched on. This led me to believe that the mount attempt wasn't even sent to the remote computer. I did a snoop on the network i/f and there was indeed no activity when I ran this command from a root shell:

sh-3.2# /sbin/mount_afp "afp://root:xxx@xxx.xxx.xxx.xxx/bbb hd" "/Volumes/bbb hd"
mount_afp: AFPMountURL returned error 1, errno is 2

So I tried a different approach and ran this:

sh-3.2# /sbin/mount_afp -i "afp://root@xxx.xxx.xxx.xxx/bbb hd" "/Volumes/bbb hd"
Password:
mount_afp: AFPMountURL returned error -5023, errno is -5023

This was confirmed in the snoop log:

Data Stream Interface
Flags: Reply (0x01)
Command: Command (2)
Request ID: 3
Error code: user not authenticated (-5023)
Length: 0 bytes
Reserved: 0x00000000

I checked the destination machine and file sharing and remote login are enabled. I can ssh into the machine and username and password are correct. Yet, when trying to use mount_afp I get "user not authenticated".

Cheers
Michael

Oct 3, 2008 11:41 AM in response to michaelw

I'm continuing my monologue here ...

I changed the root password on the remote machine because originally it contained a punctuation character. I converted it to a plain alphanumeric one and now I'm no longer getting "error 1" anymore.

However, now I'm getting get "error -5023" with or without the "-i" option.

So this seems to be the real issue - for some reason the authentication does not succeed. Any ideas?

Cheers
Michael

Oct 3, 2008 1:11 PM in response to eric_h

If you really must use the root user to connect to your host machine, that can be accomplished by entering the following in the terminal (on the machine acting as the server).

sudo defaults write /Library/Preferences/com.apple.AppleFileServer allowRootLogin '1'

But then, you shouldn't really need to do that, as there is very little benefit (if any at all) to using the 'root' user to connect. Which is presumably why it is disabled in the first place.

Oct 3, 2008 1:45 PM in response to eric_h

Brilliant - that's it. It works with a normal user!

Funny, I had started with a normal user and moved onto the root user because I couldn't get the normal user to work. Then I didn't know that punctuation chars in the password caused an issue - my normal user password does have punctuation chars as well. But at least I can now do this:

ddd:Volumes mmm$ /sbin/mount_afp -i "afp://mmm@xxx.xxx.xxx.xxx/bbb hd" "/Volumes/bee hd"
Password:
ddd:Volumes mmm$

and it works.

Many thanks eric_h 🙂

Cheers
Michael

Message was edited by: michaelw

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Can't get mount_afp to work

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.