The FreeBSD Diary
Providing practical examples since 1998If you buy from Amazon USA, please support us by using this link.
Accessing a cvs repository 16 February 2001
This article shows how to use a cvs repository to check out a local copy,
modify the contents, then check the working copy back into the main repository. It
also shows how to control the access to the main repository and how to use ssh
for the connection.
I will assume you have already read cvs - create your own repository and know how to create a repository. In this article I will use the term working to refer to a repository which exists on your local computer. The main repository will exist somewhere else. The working copy is s q what you check out, modify, then commit back to the main repository. This strategy is common practice and is The Way To Go(tm).
When I started writing this article, I was trying to get access to a cvs repository from another box. I promptly became very confused between cvs and cvsup. cvs is an Concurrent Versions System. Basically, it's a repository. cvsup is a network distribution package for CVS repositories. One is the actual repository. The other deals with distributing that repository.
The main resource for this article is http://cvsbook.red-bean.com/cvsbook.html.
Setting up the cvs server
|Most of this section was taken from The
Password-Authenticating Server and describes how to configure a cvs server. I
will assume the repository is at cvs.example.org. Here's a command I
could use for the login to that server:
I'll come back to the details of this command in a later section. For now, I will deal with the cvs server setup. The reason for showing this command is that it is directing cvs to use the pserver method for logging in. This is by far the most common access method. I'll now describe how to do enable pserver on cvs.example.org. This is accomplished with the following steps:
With the above changes, you should be able to connect to the cvs server. Provided any firewall rules allow it. Here's a simple test.
If that's what you see, then you've succeeded in setting up the cvs server. Congratulations. Now let's add a bit of security.
Adding passwords to the server
|When adding passwords to the server, make sure you don't use the same
passwords people use to login into the system. Keep them different. If the cvs
passwords are ever compromised, they can't be used to get into the rest of the system.
I put my cvs repository files under the control of a dedicated user. I
created the user especially for this task. Just use adduser. Read The
Password-Authenticating Server for more detail here.
Here's what I added to
Entries in this file are of the format:
There's a script at the above URL for generating such passwords. I suggest you use it. Note that the output from the password script is time sensitive. That's OK. It's supposed to be that way. It's not a problem. It's also not a bug. That's by design. And it does work.
Accessing the server using the password
|Let's go back to where I started. This was the command I used to
access the cvs server:
And that's it. You're logged into the
On the cvs server, the repository resides at
And when you're finished, don't forget to log out.
Since writing this article, I started using stunnel for my cvs connections.
So far I have been using the pserver method for connecting to the cvs server. This method works fine and is acceptable over trusted networks (e.g. over your own LAN). But if the Internet or other shared network lies between you and the cvs server, you might want to consider using a more secure method. Luckily, cvs is designed to use other external programs for client-server communication.
In this example, I'm going to use ssh. In my previous examples, cvs has been told that the repository exists on another box (e.g. pserver:firstname.lastname@example.org). That works well. But for this example, I'm going to make cvs think the repository is local, but it will actually reside remotely. I will use an SSH tunnel for this. This method requires that you have a shell account on the cvs server and that you an access that account from your workstation. The main reason I'm using a tunnel is because my cvs server sits behind my gateway and is NAT'd. If your cvs server is not NAT'd you can use just plain straight ssh.
If you use this method, you'll also need to use two terminal session on the workstation. One will be used for your cvs operations. The second will be used for an ssh tunnel.
My reference for this configuration is http://jakarta.apache.org/site/cvsonunix.html.
I use screen to keep that second connection in the background. Note that this command connects to port 2022 because that port is redirected to the cvs server which is behind a NAT'd gateway.
Then I detach from the screen session, leaving the ssh tunnel in the background.
Even better than screen, is this approach:
|As mentioned before, I used the tunnel because of NAT. But you can
I have tried:
because of my NAT'd gateway, but I had no success:
That's why I used the ssh tunnel instead.
But since I wrote the above, David MacKenzie wrote in with this solution:
Keep it short and sweet
|You don't have to specify the -d option with the cvs command. You
can set an environment variable:
Then you can just issue this command:
But if you are using an ssh tunnel, you should specify local host. If you don't, cvs will ignore the ssh tunnel and connect directly to the remote host and transmissions will be in clear text.
Errors I have known 19 June 2002
I encountered this error when setting up my FreshSource repository:
To fix this problem I had to do two things:
Well, I just noticed that I never mentioned
Other errors I have known 8 January 2003
I was setting up a new repo today and I really messed something up. Here was the error I was getting on the server:
I was playing with
I had missed a /. I fixed that. Then things worked.
Here is another situation I recently encountered:
This was a case of the password in