SSH on Mac OS X for Worry-Free Wireless

by Derrick Story and Rob Flickenger


Network security for projects such as webcam broadcasting isn't as much of an issue when your device is hard-wired into the desktop computer sitting on your office desk. But if you set up a wireless transmitter using an 802.11b network as described in my last article, The Industrial-Strength Wireless Webcam, you need to evaluate your environment and establish the appropriate level of security.

Once you start sending private data over the radio waves, such as your FTP user name and password, you are increasing the likelihood that some unauthorized snoop can "listen in" and grab your data.

In most home 802.11b situations, I still believe that the combination of common sense and the use of WEP provides you with the security you need for broadcasting to your hobby Web site. But what if you want to use a webcam in public and send images to a business site? Certainly you don't want to take a chance on compromising security.

In situations like this, the Unix underpinnings of Mac OS X begin to show their value. In this article, I'm going to suggest a safe solution for broadcasting your webcam images, or any other data for that matter, using the Terminal application in Mac OS X to establish a secure connection with your Web server.

Since we're talking Unix here, these techniques will work in any command line environment capable of using SSH, and we're definitely not limited to using Mac OS X for this project. So let's pop the hood and get to work.

A few words about SSH and SCP

Comment on this articleDo those of you who have some experience using pico and Mac OS X have any additional pointers?
Post your comments

SSH Secure Shell is a protocol for secure remote logins. Its key function is to prevent hackers from stealing passwords that give them unauthorized access to Web sites. SSH does this by encrypting the data (including passwords) to eliminate eavesdropping. It connects to the specified hostname, making the user prove his/her identity to the remote machine.

Once the SSH connection is established, SCP (secure copy) copies files between hosts on a network. It uses SSH for data transfer, and uses the same authentication by asking for passwords or phrases.

Mac OS X users can set up these secure connections via the Terminal application. If you haven't worked with command lines before, I suggest that you you practice first by building a couple of basic scripts. You can get more information on this from a variety of places, such as the Project Freedom Web site, or via downloadable PDFs such as Griffman's Terminal Guide. Once you're comfortable with the Terminal application, then you're ready to set up a SSH session.

Basic steps for establishing a secure wireless session with a Mac OS X client

The process for establishing secure transmission of webcam images on a public wireless network is:

  • Create a directory on your local drive and tell CoolCam to send the captured images to that directory.
  • Generate an ssh public/private key pair.
  • Set up the ssh directory on the Web server, and copy the new public key to it.
  • Test a secure copy to ensure everything is working properly.
  • Set up a cron job so that your images are are automatically sent from the local directory to the server in regular intervals.
  • Disable the cron once your webcam session is over.

Setting up your secure session on Mac OS X

Related Articles

Network Test Automation with Mac OS X and Tcl

Industrial-Strength Wireless Webcam

Life After AirPort -- New Wireless Base Stations

Using SSH Tunneling

Once you have the webcam software saving to a file in the filesystem, you're ready to set up ssh for public key operation. Both ssh and scp use the same keys to do their work, so once ssh is set up, scpwill work.

These steps assume that you don't have any other keys present on your Web server. If you do, then you already know what you're doing, and don't need this article... =)

1) Generate a new key:

rob@entropy$ ssh-keygen -d
Generating public/private dsa key pair.
Enter file in which to save the key (/home/rob/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/rob/.ssh/id_dsa.
Your public key has been saved in /home/rob/.ssh/
The key fingerprint is:
33:3c:5c:41:98:1b:fc:f5:9e:69:56:2e:0b:f1:24:7f rob@entropy

* The -d option specifies DSA keys (instead of RSA keys). The ssh v2 protocol uses DSA keys, and is widely regarded as more secure than v1.

* After entering the command, hit enter three times (to take the default filename, and to enter no passphrase.)

* Congratulations. Your public and private keys are now saved to ~/.ssh/ and ~/.ssh/id_dsa, respectively.

2) Copy the key to your Web server:

rob@entropy$ scp ~/.ssh/

* At this point, if you've never used ssh from your OS X box before, you'll be prompted to verify the fingerprint of the server's key. Answering "yes" will save the server's fingerprint in a local cache. Should the fingerprint ever change, ssh (and scp) will sound an alarm, as this could be an indication of a man-in-the-middle attack in progress.

* You will be prompted for your password on the Web server. Enter it, and the key file will be copied.

3) Test the ssh key:

rob@entropy$ ssh
ogin: Mon Oct 29 10:58:32 2001 from rob@www$

* It should log you in without a password. If not, check your work. Also check that your Web server allows public key exchange (it's on by default, and is rarely disabled. Check with your friendly local sysadmin if you're not sure.)

5) Log out, and try an scp:

rob@www$ exit
Connection to www closed.
rob@entropy$ scp /path/to/my/webcam.jpg
webcam.jpg           100% |*****************************|   601       00:00 

* It should copy the file without asking for a password. The syntax is:

scp [source file] [hostname]:[destination directory]

* This example also assumes that you have the same username on your Mac OS X client as on your Web server. If not, you can also specify a different username on the scpcommand line. For example, if your login on the Web server is webadmin:

rob@entropy$ scp /path/to/my/webcam.jpg

6) Set up cron:

Before adding a new entry to cron (sometimes called your crontab), you may want to set your editor to the user-friendly editor pico by using this command:

name% setenv EDITOR pico

Now that you've established pico as your default editor, you can set up the cron entry:

rob@entropy$ crontab -e

(This will start pico with the contents of your current crontab. Unless you've added some lines yourself, this will probably be an empty file.)

Add this line:

*/5 * * * * /usr/bin/scp /path/to/my/webcam.jpg

(This means, every five minutes of every day, do this...)

7) In five minutes, check your Web site with a browser. The updated picture should magically appear. Congratulations! Your webcam images are now being updated over a cryptographically secure channel, safe from wireless eavesdroppers.

When you are finished with your webcam, it's a good idea to tell cron to stop trying to update your Web site. To disable the cron entry, run another crontab -e in your terminal window, and comment out the line with a # symbol:

# */5 * * * * /usr/bin/scp /path/to/my/webcam.jpg

Now, whenever you want to start the auto-update process again, just delete the #, and away you go.

If you have trouble getting it going, there are excellent man pages available for ssh-keygen, ssh, and scp. You might also take a look at Rob's article on using SSH with wireless networks.

Final thoughts

This probably feels like a lot of work just to set up a webcam session. But the risks of transmitting unsecured data over a public network far outweigh the effort to set up ssh/scp. The good news is, once you've established your system, it's easy to turn on and off. As a bonus, with ssh keys in place, you can securely copy files and log in to your Web server without needing to use passwords.

If you discover a clever workaround that saves time or improves performance, be sure to let us know via the TalkBacks.

Derrick Story is the author of The Photoshop CS4 Companion for Photographers, The Digital Photography Companion, and Digital Photography Hacks, and coauthor of iPhoto: The Missing Manual, with David Pogue. You can follow him on Twitter or visit

Rob Flickenger is a long time supporter of FreeNetworks and DIY networking. Rob is the author of three O'Reilly books: Building Wireless Community Networks, Linux Server Hacks, and Wireless Hacks.

Return to the Wireless DevCenter.

  • SSH Problem with Instructions
    2001-11-22 08:21:08  cochella [View]

    Great article; clear concise.

    However, I am unable to repeat the SSH public/private key login process.

    I following the instructions exactly and was always prompted for a password and not a passphrase (I chose to provide a passphrase).

    The closest I can get to being prompted for a passphrase (I also get prompted for a password after entering the passphrase) is to do a few changes:

    1. On the remote host put the public key in .ssh2/ and create a file called "authorization" that contains "Key". This is for multiple keys I believe.

    2. Edit the key on local and remote to remove "ssh-dss" at the beginning of the key file and the "username@localhost" at the end of the key file.

    After doing all of this I still get the following session:

    ssh -l chris
    Enter passphrase for key '/Users/cochella/.ssh/identity':'s password:
    Last login: Thu Nov 22 09:28:36 2001 from
    [chris@server1 cochella]$

    If I understand everything this means that passphrase encryption (based on the keys) did not take place and a lesser form of encryption via the password was executed. Is this correct?

    How can I fix this?

    I have been forward and backward with all possible combinations and verifying passwords.

    Thank you,


    Local System: Mac OSX 10.1
    Remote System: RedHat 6.2 running openssh