Internet Bandaid   [RSS Feed]

Archive for the ‘svn’ tag

Svn Ignore Directory

without comments

This is a note-to-self.    Sometimes when I want svn to ignore a whole bunch of files in a directory (example, I want svn to ignore files in my ./user_upload/ directory), I should follow the instructions below, which came from another forum.


$ svn mkdir spool
$ svn propset svn:ignore ‘*’ spool

—-

The value of svn:ignore is the list of file patterns to
ignore. See:

http://svnbook.red-bean.com/en/1.1/ch07s02.html#svn-ch-7-sect-2.3.3

So you have two options, depending on whether you want the spool
directory itself to be in version control and have its contents
ignored, or whether you want the directory itself ignored as well.

If you want the former, create the directory, add it, then set the
svn:ignore property of that directory to ‘*’ to ignore everything in it.

$ svn mkdir spool
$ svn propset svn:ignore ‘*’ spool
$ svn ci -m ‘Adding “spool” and ignoring its contents.’

If you want the latter, do not add the directory, but rather set the
svn:ignore property of the parent directory to ‘spool’.

$ mkdir spool
$ svn propset svn:ignore ‘spool’ .
$ svn ci -m ‘Ignoring a directory called “spool”.’

If you had already added the spool directory but now realize you did
not want to, but want to preserve its contents, you can fix it this way:

$ svn export spool spool-tmp
$ svn rm spool
$ svn ci -m ‘Removing inadvertently added directory “spool”.’
$ mv spool-tmp spool
$ svn propset svn:ignore ‘spool’ .
$ svn ci -m ‘Ignoring a directory called “spool”.’

Written by John Lai

September 1st, 2009 at 10:52 am

Posted in Uncategorized

Tagged with , ,

Recover Deleted SVN File

without comments

I keep forgetting how to do this, so I’m going to write the steps down here.

Type the following to see a log of revisions:

bash> svn log -v

Once you’ve spotted the file and the version you want, type

bash> svn up myoldfile.txt -r29

Replace myoldfile.txt with the name of the file you want to recover, and 29 with the version number of the file you want to recover.

Now you’ve got your file back but it’s still registered as the old 29 version. So you’ll need to make a copy of it and then do an “svn add” to include it as a recent version.

Written by John Lai

April 8th, 2009 at 6:36 pm

Posted in Uncategorized

Tagged with ,

SVN Access via SSH keys for Linux and Windows

with 4 comments

Many shared hosting packages offers only 1 SSH account, which can be a problem if you have many developers each needing his/her own unique credentials to access the server. This is especially the case if you have multiple developers needing to access a single subversion repository.

In this post, I outline the steps to offer a client machine (your developer) unique SSH credentials for server access via SSH keys. I follow up by showing how they can connect to your svn repository.

Step A: Setup on Client’s Linux Machine

// Performed by client (the developer)

If you use a unix-like OS, continue reading this step. If you use a Windows OS, skip this step and go to Step B.

1. Open up the terminal/shell.

2. On the command line, type:

ssh-keygen -t dsa

3. When prompted to enter file name, type:

mykeys

4. When prompted for a password, you can leave it blank and hit enter, or type in a password. Because we are authenticating via keys, it is not necessary to use a password.

5. Now you should have two files:

a) mykeys – the private key you keep to access the server
b) mykeys.pub – the public key you give to your systems administrator

6. Copy mykeys to the ~/.ssh directory.

7. Rename mykeys to id_dsa.

8. Give mykeys.pub to your systems administrator.

You are done. When your systems administrator installs the mykeys.pub on his end in Step C, you will be able to access his server via ssh using the new password you chose.

Step B: Setup on Client’s Windows Machine

// Performed by client (the developer)

If you use a windows OS, continue reading this step. If you use a unix-like OS, avoid this step and perform only Step A.

1. Go to http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and download putty.exe and puttygen.exe.

2. Open puttygen.exe.

3. From the main menu, select Key>SSH-2 DSA key.

4. Press the Generate button.

5. Move your mouse cursor around to generate randomness as instructed by the program.

6. When key is generated, you may choose to fill in the keyphrase passes or leave them empty. Because we are authenticating via keys, it is not necessary to use a password.

7. Copy the contents in the “Public key for pasting into OPENSSH authorized_keys file:” into a text document. Save the text document as mykeys.pub.

8. Save private key as mykeys.ppk.

9. Send mykeys.pub to your systems administrator. Wait for him to configure things in Step C before continuing.

10. When your systems administrator is finished with Step C, you are ready to set up Putty SSH and SVN access. Open up Putty and fill out the Host Name.

11. In the Saved Session, type in a Session Name that you can easily remember. It will be used by svn later on.

12. On the left hand side, go to Connection>SSH>Auth and find the mykeys file for the private key field.

13. Go to Connection>SSH and make sure SSH 2 is selected.

14. Go back to the first Putty screen and save these settings.

15. Test the new SSH Key by clicking Open. Putty will prompt you for the private key password you chose earlier.

16. Download and install Tortoise SVN for Subversion access.

17. When Tortoise is installed, the path to your svn repository is

svn+ssh://username@sessionname/serverpathtorepository

The username is the ssh account username. The sessionname is the Session Name from step 11. This Session Name links back to the settings saved by Putty. When you log in, Tortoise will prompt you for your ssh key password.

You are done.

Step C: Setup on Unix-like Server

// Performed by systems administrator

1. Obtain the mykeys.pub from your client.

2. Copy the contents of mykeys.pub and append it to the file ~/.ssh/authorized_keys2 (if the file does not exist, create a blank document first and then append).

3. In the /pathtorepository/conf/passwd file, add a new username – password pair.

Your server is now ready to accept ssh access from your client. Repeat these steps for additional clients, and append the public keys to authorized_keys2.

Written by John Lai

February 13th, 2009 at 6:45 pm

SVNserve (Subversion) on 1and1

with 2 comments

** A new post has been written on this subject. Please read SVN Access Via SSH Keys for Linux and Windows for an updated and working solution (works on 1and1 as well).


—– Old Original Post ——-

I spent the week trying to get Multiple Subversion User Accounts to work on a 1and1 Linux Business Package. I FAILED. The 1and1 tech team told me they do not allow it.

As many of you know by now, the 1and1 Linux Business Package only gives you one SSH account. Ideally, you do not share this ssh account because it opens up your entire shared server, including access to svn (via svn+ssh tunnel mode – instructions here).

First, I tried to run svnserve in daemon mode and failed. I discovered 1and1 runs a crontab to kill svnserve daemons every minute. I tried to write my own crontab to revive the daemon, but that didn’t work.

Second, I tried to run svnserve in inetd mode, but because I do not have access to inetd.conf (makes sense..i’m on a shared server), this option failed.

Third, I tried to use public key authentication to allow multiple users to ssh into my shared server without knowledge of my ssh password. 1and1 does not allow public key authentication unless you’re using putty public key authentication, which isn’t the same thing. So this option failed too.

In the end, I released my sole ssh credentials to my developers, which they used to ssh tunnel into my repository.

1and1 said they allow svnserve on their dedicated and virtual servers.

———

** A new post has been written on this subject. Please read SVN Access Via SSH Keys for Linux and Windows for an updated and working solution (works on 1and1 as well).

Written by John Lai

September 8th, 2008 at 9:51 pm