Difference between revisions of "Enable FTP Server"

From AwkwardTV
Jump to: navigation, search
(ATV Take 2 FTP)
(FTPD Installation)
Line 16: Line 16:
'''Give super-user privileges:'''
'''Give super-user privileges:'''
<pre>sudo -s</pre>
<pre>sudo -s</pre>
'''ftpd directory for ATV 3'''
You have to substitue the path to ftpd in ATV 3 from /usr/libexec/ftpd to:

Revision as of 05:23, 5 December 2009

Why Standard FTP?

Why would you want to turn on a standard, non-secure FTP server on your ATV?? Well the answer for me was simple . . . SPEED!!!

Here's my setup as an example: iMac -> wireless 802.11n -> Airport Extreme -> Ethernet cable -> ATV

SFTP - Avg xfer speed = 2Mb/s
FTP - Avg xfer speed = 7Mb/s!!!!!

That alone was a good enough reason for me! If you're worried about security then you should stick with the SFTP server which is usually installed when using the Patchstick.

FTPD Installation

There is already an FTP server on the AppleTV just waiting to be activated. It's relatively simple to do so. Cut and paste the seperate code blocks into a terminal window:

Give super-user privileges:

sudo -s

ftpd directory for ATV 3 You have to substitue the path to ftpd in ATV 3 from /usr/libexec/ftpd to:


Write the FTP configuration file:

cat <<EOT > /System/Library/LaunchDaemons/ftp.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

Reload that configuration file after changing it:

launchctl load /System/Library/LaunchDaemons/ftp.plist

Simple as that. It should start working right away.

ATV Take 2 FTP

To enable FTP server in ATV Take 2 you will also need to copy the following file which is missing in Take 2: ftpd.

Copy it from /usr/libexec/ftpd (tiger) to the same location on the ATV. Alternately, you can find an updated ftpd in MacOSXUpdCombo10.4.11Intel.dmg Don't forget to chmod +x ftpd

If you have a 1.0 recovery partition do the following (Don't have a 1.1 image to test):

sudo mount -uw /
sudo touch /.readwrite
cd ~
sudo dd if=/dev/disk0s2 of=recovery.dmg bs=1m
hdiutil mount recovery.dmg
hdiutil mount /Volumes/Recovery/OS.dmg
sudo cp -p /Volumes/OSBoot\ 1/usr/libexec/ftpd /usr/libexec/ftpd
sudo chmod +x /usr/libexec/ftpd
sudo chown root:wheel /usr/libexec/ftpd

For ATV 2.1 you must also add "frontrow allow" to the /etc/ftpusers file so that you can login with the frontrow user.

From your local machine, copy the /etc/ftpusers file to your local machine

scp -1 frontrow@appletv.local:/etc/ftpusers $HOME/Desktop

The file will be copied to your Desktop. Open it with TextEdit (or your favorite ASCII editor, since I'm a geek I prefer 'vi'), and add the "frontrow allow" line to the end of the file.

After the edit your ftpusers file should look like this:

# list of users disallowed any ftp access.
# read by ftpd(8).
frontrow	allow

Ensure that you DO NOT add the ".txt" extention to the file, it should only be called "ftpusers".

All that remains is to copy it back to your ATV, ssh to your ATV, change the ownership and copy it back to the correct location.

From your local machine:

scp -1 $HOME/Desktop/ftpusers frontrow@appletv.local:~
ssh -1 frontrow@appletv.local
 <enter 'frontrow' as the password when prompted>
sudo chown root:wheel ftpusers
sudo mv ftpusers /etc/ftpusers

B) Then perform the steps listed above for the 1.x installation

Anonymous Write Access

To allow anonymous access (with write support) several steps need to be taken. Don't do this if your Apple TV is directly connected to the internet for what ever reason!

There are several steps here which may not be required - so this may need a little cleaning up.

Get into the correct state

sudo -s

Create the directory where the anonymous user can dump files

mkdir /mnt/FTP
chmod a+w /mnt/FTP

Write the ftpd.conf file:

cat <<EOT > /etc/ftpd.conf
umask all 022
modify        guest
chroot  GUEST   /mnt/FTP/

Allow the anonymous user to connect

echo 'anonymous allow' >> /etc/ftpusers
echo 'ftp allow' >> /etc/ftpusers

Create the FTP user

niutil -create / /users/ftp
niutil -createprop / /users/ftp uid 502
niutil -createprop / /users/ftp gid 501

Restart the FTP server (this is the only way I know how short of restarting the system)

launchctl unload /System/Library/LaunchDaemons/ftp.plist
launchctl load /System/Library/LaunchDaemons/ftp.plist

Once this is done you can browse to your Apple TV, for example, from Windows Explorer by entering ftp://your.appletv.ip/. You will be taken directly to the /mnt/FTP/ directory, allowing you to drag and drop files across directly. I found this faster (no encryption) and easier than using SCP, plus most OS's have an integrated FTP client these days.