Friday, July 20, 2007

Using Eclipse and CVS Source Code Control on Mac OS X

The new project I just joined is waiting to get their source control system installed...so in the meantime -- I felt inclined to provide a interim solution until their permanent server arrives.

I was able to get a local copy of CVS up and running on my MacBook Pro. Along the way - I learned a little more about the Mac Firewall and service configuration that I thought I'd share... (this stuff isn't obvious to somebody who just switched to the Mac)

The following article from Apple gives very good instructions about how to run CVS via command-line instructions: Version Control with CVS on Mac OS X

That's the easy part -- running CVS via command-line worked right away without any problems. The challenges started when I tried to connect Eclipse to the CVS server hosted on my Mac.

First, Eclipse needs to connect to CVS through a network connection. And by default ssh is disabled. If you type the following command - you may see the same error I did:

ssh your-machine-name
ssh: connect to host your-machine-name port 22: Connection refused


The recommended way to establish communication to CVS is via SSH - and although SSH is pre-installed on OS X, it is disabled by default. You will need to enable SSH to support secure host communications. Visit System Preferences / Services



And while you are there - it would be a good idea to click the "Firewall" button and enable the mac Firewall (it's DISABLED by default!). And be sure to check "Remove Login - SSH" to let SSH connections through the firewall.

Next - start a Terminal Session (Applications/Utilities/Terminal) to test ssh connectivity using the following command:

ssh your-machine-name


If enabled, you should not be prompted for a password. You may also see the following error: "The authenticity of host...can't be established." This is because we are cheating slightly and not generating SSH host keys. Ignore this for now and when prompted "Are you sure you want to continue connecting" - answer YES. In my case - I was connecting from my own machine to my own machine's CVS server. For other machines - I will expend the extra effort to generate SSH keys and pass their public keys to the client systems.

Now - cvs is installed, and ssh is configured. The next step is to connect eclipse to CVS. I found this link to be very helpful: Eclipse and cvs

Screen-shots of my eclipse settings are below:

Eclipse - Ext Connection Method configuration window.





Eclipse - CVS Repository settings




So if you want to use SSH at its default port of 22 - then you are done.

But if you want a more secure environment -- I took the extra steps to choose a different port number for SSH as recommended in this security article (See Rule#4):

Basic Mac OS X Security

You may with to do the same to confuse people scanning for Port 22.

1 comment:

Anonymous said...

Thanks your tip helped me solve my problem.