CVS over SSH


It is actually quite easy to set up CVS over SSH, at least for the command-line version. As that's what I use, I don't keep up with what the GUI wrappers and replacements can do.

What you need

You need CVS, SSH, and the ability to set up environment variables.


First, make sure you can log in to the remote machine with SSH. If you can't log via SSH, then you have some other problem that you need to resolve first. Once you can log in to the remote system with ssh, make sure you can run a remote command. (For example, "ssh user@remotehost ls" should return the same listing as if you'd ssh'd in to the remotehost and type "ls".)

Note: It's generally a good idea to generate SSH keys. With the standard versions of SSH and openSSH, you use the "ssh-keygen" command to do this. This will speed things up, as well as allowing you to make the access to a CVS repository a bit easier.


Next, make sure that the same version of CVS is running on both the local and the remote machine. Running "cvs --version" will tell you the version of CVS you are using. If you are using different versions, you may have wierd problems. CVS can work with different versions, so you can skip this if they are fairly close. If you have problems, however, this is one of the first things you should fix.

We'll also make better progress if there is a CVS repository set up on the remote machine already.

Environment Variables

Now we need to set the environment variables. We must set CVS_RSH (the underscore is important), and if we set CVSROOT (the lack of an underscore is important) then the job is that much easier.


The CVS_RSH environment variable should be set to the path of the SSH executable. On a new system, I typically run something like setenv CVS_RSH `which ssh` to make sure everything works, and then I once I get everything working, set the environment variables in the appropriate shell startup scripts.

One of the most common mistakes is to set the CVS_RSH variable to the directory containing the ssh executable, or to install an ssh program where the invoke-a-command-remotely program is not named ssh, yet ssh was specified as the executable program to invoke.


The CVSROOT environment variable is optional. If you don't set it (or wish to use a different value) you can specify it on the command-line. Either way, the value is a specially-formatted string.

The format of this string well-documented, but for our purposes, it should be:



Once we have CVS and SSH installed, verified, and have set up the CVS_RSH and CVSROOT environment variables, we can use CVS just as we would if we were running it locally, with a little bit more overhead. You check out a module with "cvs checkout modulename", add new files with "cvs add filename", commit changes with "cvs commit" / "cvs commit filename", etc. etc.

Further, we don't have to log in to the remote machine (difficult to do if you're using a dialup or laptop) to do our work. We only need to be on the network when we're using the CVS commands, and not while developing.