Friday, April 9, 2010

Start OS X TFTP Server using launchd

I had trouble with my TFTP Server application today which caused me to go digging and figure out how to run the TFTP server in OS X without an application to help me.

Steps:
1. Edit the configuration
2. Start the server
3. Create a file with the appropriate file name and permissions
4. Stop the server

Edit the TFTP configuration file:


sudo vi /System/Library/LaunchDaemons/tftp.plist


You will probably want to edit the TFTP Directory string here:

 /usr/libexec/tftpd # The TFTP daemon
 -s # Enables the directory option. We're going to supply a directory next.
 /Users/my_username/Public/tftp # I edited this field with a directory I can find easily.



:wq # write and quit



Start the TFTP Server using launchd (launchctl):


sudo launchctl load -w /System/Library/LaunchDaemons/tftp.plist



Stop the TFTP Server:


sudo launchctl unload -w /System/Library/LaunchDaemons/tftp.plist
# For future reference when you want to stop the server. TFTP uses no authentication so you don't want to leave it on longer than you need it.

Help:


man tftpd
# The tftpd man page is very good

Pay close attention to this rule:

"Files may be written to only if they already exist and are publicly writable."

If you're using tftp to put a file from another system onto your system you need to create a file with that filename on your system before you try to put it on your system. You can do this using the "touch" command.


cd /Users/my_username/Public/tftp/


touch my_file.example
# Creates a tiny empty file with the name you give it

chmod 666 my_file.example
# You may need to chmod the file so that "other" can write to your file

Now that you've created this placeholder file and applied the appropriate permissions to this placeholder file you can go to your source system and send the file from your source system to your target system.


No comments:

Post a Comment