Mac OS X 10.3, 10.4: Configuring AFP to use OpenSSH exclusively
Learn how to configure an AFP (Apple File sharing Protocol) client to exclusively use OpenSSH as the connection method, instead of a clear connection. This is an advanced document for Mac OS X 10.3 and 10.4.
AFP includes a feature to use OpenSSH as the data transport mechanism. To prevent OpenSSH from using a clear connection, these three preferences must be set by editing a configuration file (com.apple.AppleShareClientCore):
Enables the feature and instructs the client to try OpenSSH if the server advertises it
Instructs the client to use OpenSSH even if the server does not say it is available
Causes the login attempt to fail if OpenSSH cannot automatically connect
Important: This settings must be made for each user account. They cannot be made globally.
Note: When these settings are in effect, if OpenSSH cannot establish a connection a "bad password" dialog box appears. The most common cause of OpenSSH failure is when the host key for the server is unknown or is changed. Administrators should distribute and maintain the /etc/ssh_known_hosts files in accordance with best security practices. Without the /etc/ssh_known_hosts file, users will need to manage their own known_hosts file and pre-establish the correct server key.
Editing the configuration file
There are two ways to do this:
Manually edit the file
Open the .GlobalPreferences.plist (which is in each user's ~/Library/Preferences/ folder) in a editor such as TextEdit. Change the three preferences described above.
Repeat this process for each additional account's .GlobalPreferences file.
Make a script
The following script can be saved into a file and run once for every account that will be using AFP over SSH. Follow these steps:
- Create a new document in TextEdit.
- Copy and Paste in the text that is in the section below, beneath "Begin copying below this line"
- Choose Make Plain Text from the Format menu.
Tip: If this command is not present in the Format menu, skip this step (as you have already set plain text as the default format).
- Save this file to the /Users/Shared folder with the name "SecureAFP.command"
Note: Do not append the txt filename extension to the file.
- Open the Terminal application (located in the Utilities folder).
- Type: sudo chmod 555 SecureAFP.command
- Press Return.
- Enter your administrator password when prompted.
- Run the script by double-clicking it in the Finder.
- Log in with a different account, and use the same script.
- Repeat for other accounts as needed.
Begin copying below this line:
$defs = `defaults read -g com.apple.AppleShareClientCore`;
$defs =~ s/"afp_ssh_(allow|force|require)"\\s+=\\s+[^;]+;/"afp_ssh_\\1" = 1;/gs;
system qw(defaults write -g com.apple.AppleShareClientCore), $defs;
#end of script
End copying above this line.
Note that the script's lines begin, respectively, with "#!", "$ENV", "$defs", "$defs", "system", and "#end"
OpenSSH requires access to a user's home directory, so you can't use this method to mount the user's home directory.
AFP connections initiated by the automounter cannot use OpenSSH.
When using OpenSSH the AFP client will not attempt automatic reconnect.
Since OpenSSH only works over TCP/IP, you cannot use this method to communicate to a server over AppleTalk.