paint-brush
Mounty — macOS Samba Share Mounting Toolby@x0054
1,007 reads
1,007 reads

Mounty — macOS Samba Share Mounting Tool

by BogdanSeptember 23rd, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Fri, Jul 31, 2015

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Mounty — macOS Samba Share Mounting Tool
Bogdan HackerNoon profile picture

Fri, Jul 31, 2015

A few years ago I was looking for a way to automatically mount a server share on my MacBook when I was connected to my home WiFi. In fact I had several shares at home and at my office that I used on regular basis. I didn’t want to always have to manually reconnect to them. After some research, I found a tool in the AppStore that claimed to do just this, but I wanted something that could work in CLI and could be scriptable. Thus Mounty was borne.

About Mounty

Mounty is a tool for mounting remote shares on OSX. It takes WiFi SSID as an argument, and attempts the connection only if the SSID matches the network the system is currently connected to. It also verifies that the share isn’t already mounted. If it is, it returns the location where the share is already mounted, rather then attempting to mount it again.

Mounty is superior to the unix mount command available in OSX because it can store the credentials for the network share (username and password) in the keychain. This makes it ideal for use in bash scripts. For instance, you can make a bash script that calls mounty several times, iterating through all kinds of network shares you connect to on regular basis. Simply add that script to cron, and you’ll never have to worry about manually remounting those shares again.

I added the SSID argument so that monty knows to only attempt the connection if the system is connected to the right network. This is ideal for laptops, if you work in several different locations, and need to access different network shares, based on the location.

Installing Mounty

You can find a copy of Mounty on GitHub. Just grab the source and compile it in Xcode, or download the latest compiled binary. To install simply copy it to your computer, for instance to /usr/bin/.

Using Mounty

Run it in the terminal like this:

mounty smb://server/share /mount/pint WiFi_SSID

It works with any type of share that OSX can mount, not just samba, as it relies on the internal NetFS library. The first time you connect to a password protected share, a GUI popup dialog will ask you for the password. After the first time, the password will be safely saved in the Keychain and you will not be bugged again. This means you can use Mounty in BASH scripts without the need to also include your password in the script.

Final Thoughts

Hope you like Mounty. Use it, love it, fork it, make changes, send pull requests. Enjoy!

Originally published at sdbr.net.