tftp and launchctl on MacOSX
An utility which helps you to utilize and configure the TFTP server shipped with the standard Mac OSX distribution. Using this application you can start/stop the TFTP service on your Mac. Download FileZilla Client 3.50.0 for Mac OS X. Microsoft Azure Blob and File Storage Transfer files to the Azure cloud using Microsoft's Blob Storage and File Storage services. The tftp client for Linux and OS X is very similar. When invoked, it gives the user a prompt and takes commands from the standard input. Binary mode can be set with command-line flags - in OS X, the '-e' flag sets binary mode (among other things which are less important), and in Linux '-m binary'. Tried the MAC built in TFTP, couldn't get it to work. Found this and it is a cinch, so easy. I used it to flash a Buffalo router in just a few minutes after trying other methods for a day.This is. In this article I will be detailing how you can use the Terminal (Mac) as an FTP or SFTP client, to do a variety of tasks on remote servers. For the purpose of illustration, I’m using a test server with Linux, Apache, MySQL and PHP installed on it, with SSH access enabled.
© May 2019 Anthony Lawrence
I needed to upgrade the firmware in a Fortinet Firewall. That's done by pointing the Fortinet at a tftp server that has the new firmware image. Simple enough.. except where do I have a tftp server?
Os X Tftp Server
Well, not on my main Linux server, because it apparently isn't important enough to install on spec. I could of course go get it, but instead I took a look on my Mac. I honestly didn't expect to find it: I thought they might reserve that for the Server version of Mac OS X, but no, there it was, man page and all. The man page warns:
Well, I don't normally want tftpd running, so launchctl is the obvious choice. Fire that up with 'sudo launchctl' and then type:
Why '-F'? Because by default, the tftp.plist contains:
If you leave out -F, launchctl will say 'nothing found to load',which isn't very helpful - what it really should say is 'I can't load this because it's presently disabled'. The -F forces it to ignore that little impediment..if you don't use sudo, it will say:
Assuming you had neither problem, some fraction of a second later, tftpd is ready to run (well, LaunchD is ready to listen for tftpd requests and start it up, but you get the idea). Where's your tftpd directory? Not in /tftpboot where you might expect to find it on a Unix system.. the tfpt.plist actually specifies the program arguments, and by default itlooks like this:
So '/private/tftpboot' is where you want to put the files to be accessed. When you are ready to shut tftp off, just tell launchctl:
If you did want tftpd to run all the time, you would use
That changes the 'Disabled' key so that the file now has this:
'tftpd' would now be enabled at each boot. Should you later change your mind, 'unload -w /System/Library/LaunchDaemons/tftp.plist' will put things back as they were.
Got something to add? Send me email.
(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version
-> -> tftp via launchtl on Mac OS X Leopard for firewall firmware upgrade.
Inexpensive and informative Apple related e-books:
Take Control of Apple Mail, Third Edition
El Capitan: A Take Control Crash Course
Take Control of IOS 11
Are Your Bits Flipped?
Take Control of the Mac Command Line with Terminal, Second Edition
If you’re working with networking devices such as switches, routers or firewalls, to upgrade their firmware, you more often than not need a TFTP server. Here’s how to use the one included with Mac OS X or macOS.
Preparation
Mac OS X has a tftp
server included, and you just have to start it and do a little configuration.
I found and set it up this way:
Find appropriate commands
Use the apropos
command to see if there are any commands related to tftp
. From Terminal:
Tftp Server For Mac Os
The command replies:
Since the commands exist, you can use man
to get more info. We would want the server version of this command, so that is the one with the d
suffix (d is for “daemon”).
Looking at these results and Apple’s online version of the man
info, we see it says:
This server should not be started manually; instead, it should be run using launchd(8) using the plist /System/Library/LaunchDaemons/tftp.plist
. It may be started using the launchctl(1) load command; refer to the documentation for that utility for more information.
Start tftpd
The man
file gives you the plist to use, so, you just start it with launchctl
:
… and tftpd
will start. Supply your password when sudo
prompts for it.
You can confirm it’s running using netstat
to check what is listening on its port, traditionally port 69
.
It will show:
Serve a Firmware File
Now that the tftpd
server is started, you need to put the firmware binary file in a specific location for the tftpd
to be able to serve it to a requesting device. Namely your firmware files should be saved to /private/tftpboot
. The tftp.plist
file looks like this:
Symlink the tftpboot folder
You used to be able to change the tftpboot
path, but OS X El Capitan and later macOSs have stronger security via their “SIP” system which makes things more difficult. Just symlink the tftpboot
to a folder you have full control over. You can do it like this:
That being said, please note that I tested a fresh macOS Sierra install directly on /private/tftpboot
, and tftp get
and put
from another Mac worked fine without the symlink in place, so YMMV. I confirmed with csrutil status
that SIP is indeed enabled on my fresh macOS.
Japanese Mac keyboards don’t handle reverse solidus . To enter one you can press
option-¥
.
Japanese Mac keyboards don’t handle reverse solidus . To enter one you can press
option-¥
.
Copy firmware file into position
Now let’s serve a file. Let’s say we download a firmware for an HP switch, and want to upgrade its firmware to that version. The file downloaded is F_05_80.swi
and is saved to our Downloads
folder. Let’s move it to the correct folder, and set its permissions.
Get firmware file from tftpd
It differs by each device you’re upgrading, but typically you would set these:
- Method of upgrade: select
tftp
usually. - IP address of
tftpd
server. This is the IP of your mac. - Name of firmware file. Enter the exact name, getting the case exactly right.
Then there is usually a way to “execute” the transfer by a command or menu. Once the firmware is transferred and loaded, your device will usually restart.
Click the screenshot to see what it looks like on an HP switch.
Put a file from a device to tftpd
Sometimes you want to save a file from the device, to your tftp
server. The tftp
protocol is dumb and requires no authentication, so you need to specify in advance what the received filename will be. Use touch
to do that.
Be sure to get the name exactly right, as mis-spellings are a common cause of errors here.
Be sure to get the name exactly right, as mis-spellings are a common cause of errors here.
Now you have a blank file that will be overwritten, when you specify it from your remote device. Make sure you specify exactly the same filename.
Stop tftpd
Be sure to unload the service when you’re not using it:
The aforementioned netstat
command should return nothing.
Alternatives
There are a couple of GUI alternatives you can try, though I have not done so myself:
I hope this information helps someone.
Acknowledgements:
The banner photo is a photo I took of a Cisco Catalyst switch my company eSolia installed for a client. It probably needs upgraded!
Tftp Client For Mac
About the Author
Tftp For Mac Os
I'm Rick Cogley, and thanks for reading. I'm an experienced technologist, co-founder & -owner of eSolia Inc. I'm from America originally, but have been helping people and companies succeed in Japan since 1987. I'm an avid jogger, lover of music and puzzles, and family man with a wonderful wife and daughters. Please do me a favor and share and link to this post, comment on it, and maybe connect with me on other social sharing sites as well. Cheers!