Difference between revisions of "Enable FTP Server"
m (→Anonymous Write Access)
|Line 147:||Line 147:|
Revision as of 16:54, 18 August 2010
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.
ATV Take 2 FTP
To enable FTP server in ATV Take 2 you will need to copy
ftpd which is missing in Take 2.
Get ftpd from an Intel Mac
From a Mac OS 10.4 (aka "Tiger"), copy:
on the ATV to:
Log into your AppleTV and:
sudo -s chmod +x /usr/bin/ftpd
Alternately, you can find an updated
ftpd in MacOSXUpdCombo10.4.11Intel.dmg
Get ftpd from the recovery partition
The recovery partition contains the file we are looking for. At least mine, which started as a AppleTV 1.1 and has been upgraded to 3.0.2.
Get the file:
sudo -s INSTALL_SOURCE='/tmp' DAEMON='usr/libexec/ftpd' dd if=/dev/disk0s2 of=$INSTALL_SOURCE/recovery.dmg bs=1m hdiutil mount $INSTALL_SOURCE/recovery.dmg hdiutil mount /Volumes/Recovery/OS.dmg cp -p /Volumes/OSBoot\ 1/$DAEMON /usr/bin/ chown root:wheel /$DAEMON hdiutil unmount /Volumes/OSBoot\ 1 hdiutil unmount /Volumes/Recovery -force chown root:wheel /usr/libexec/ftpd
With this, you can proceed to enabling FTP as for an ATV Take 3.
ATV Take 3 FTP
On the AppleTV Take 3, there is already an FTP server just waiting to be activated.
Write the FTP launch daemon file:
PLIST_FiLE='/System/Library/LaunchDaemons/ftp.plist' cat <<EOT > /$PLIST_FILE <?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"> <dict> <key>Label</key> <string>com.apple.ftpd</string> <key>Program</key> <string>/usr/libexec/ftpd</string> <key>ProgramArguments</key> <array> <string>ftpd</string> <string>-l</string> </array> <key>Sockets</key> <dict> <key>Listeners</key> <dict> <key>Bonjour</key> <true/> <key>SockServiceName</key> <string>ftp</string> </dict> </dict> <key>inetdCompatibility</key> <dict> <key>Wait</key> <false/> </dict> </dict> </plist> EOT
Load the FTP daemon:
launchctl load $PLIST_FILE
Allow FTP access to user
USERS_FILE='/etc/ftpusers' cat >> $USERS_FILE <<CODE frontrow allow CODE
After this, your
/etc/ftpusers file should look like this:
# list of users disallowed any ftp access. # read by ftpd(8). Administrator administrator root uucp daemon unknown www frontrow allow
You should be ready to make an FTP access from your computer to the AppleTV.
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
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/ EOT
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.