Introduction to SVN + SSH principles
Most articles on the Internet are about how to configure subclipse in a Windows environment and use reposiotry that can access the svn + SSH protocol. Here we will introduce how to implement it in a Linux environment.
In short, SVN + SSH establishes SVN communication through the SSH channel. Generally, SVN + SSH repository is built on a Linux server to generate two keys, one public key, one private key, and the other public key on the server, the private key is placed on the client. The client that holds the private key sends a connection request to the server through the SSH channel. The server requires that the user's passphrase in the Linux system be entered. If the user's password phrase is correct, check whether the private key on the user's hand is paired with the public key on the server. If it is paired, the request is passed; otherwise, an error is prompted and the user request is rejected. For details about how to build a reposiotry SVN + SSH protocol on a Linux server, refer to: http://jimmyg.org/blog/2007/subversion-over-svnssh-on-debian.html, this article gives a very detailed description.
Import the key and log on to the SSH host
Next, let's take a look at how the Linux client uses subclipse to access the svn + SSH host, instead of generating and configuring the server's key.
As a general developer, if your team uses SVN + SSH protocol to build a reposiotry, when you join the team to prepare for development, someone will send you a private key file and a passphrase. For private key files, there may be two formats. You must know which format is in your hand, the two formats are:
1. Putty private key (putty Private Key) in putty format ending with. PPK. It is a text file with the following content:
2. The other is a pure keystore file with no fixed suffix. It is generally a. txt file or no suffix. This is the original OpenSSH private key file generated by the server using OpenSSH. Its content is roughly as follows:
In Linux, if you get the private key file as the latter, you can use it directly in Linux. If you get the former, a PPK file, you need to use Putty to convert it to OpenSSH format. The conversion method is very simple:Open puttygen.exe-> conversations-> Import key-> select your PPK file and return to the main window-> conversations-> export OpenSSH keyYou can.
Assume that we have obtained or converted the private key in OpenSSH format. Next, let's take a look at how to use this file to log on to the SSH host. Assume that your account is user and the Directory host is svn.abc.com. Use the SSH command to log on in two ways:
Method 1: Use the-I parameter to specify the private key file:
Ssh-I/path/to/private-key/user@svn.abc.com
Passphase prompt in the middle. Enter passphase.
Method 2: By default, SSH will automatically search for the private key file from the. Ssh folder in the user's home directory. Therefore, it is more convenient to put the private key file under the. Ssh folder. (If there is no. Ssh folder in your home folder, use mkdir ~ /. Ssh creation ). The name of the private key file placed in the. Ssh folder is also specified. view the SSH command instructions. We can see that the main private key file sets the default file name according to the encryption method:
~ /. Ssh/identity
~ /. Ssh/id_dsa
~ /. Ssh/id_ecdsa
~ /. Ssh/id_rsa
Contains the private key for authentication. These files contain sensitive data and shocould be readable
By the user but not accessible by others (read/write/execute). SSH will simply ignore a private key
File if it is accessible by others. It is possible to specify a passphrase when generating the key
Which will be used to encrypt the sensitive part of this file using 3DES.
If the obtained private key is encrypted using RSA, run the following command to copy the key to the specified location:
SCP/path/to/private-key /~ /. Ssh/id_rsa
After the copy is complete, use:
SSH user@svn.abc.com
Check whether you can log on. If you log on with the function, the private key has been placed in the correct position. If any problem occurs, you can append the parameter-vvv to view the log.
Configure subclipse to access SVN + SSH Repository
This step is very simple. Similar to the practice on Windows, subclipse does not need to be configured. You only need to add an environment variable: svn_ssh, however, as mentioned in some articles on the internet, you only need to set svn_ssh to an SSH command that specifies the private key file, for example:
Export svn_ssh = "ssh-I/path/to/private-key/
The difference is that in my environment, you must set the login user name and host to be valid, that is, my svn_ssh looks like this:
Export svn_ssh = "ssh user@svn.abc.com"
The specified private key file is not displayed because it has been placed in the default location.
After the svn_ssh environment is set, log on to the system again, open eclipse, and use subclipse to create SVN + SSH repository.
Use SSH-agent and SSH-add to cache password phrase passphrase
After using subclipse to successfully access the repository of the VN + SSH type, one problem is that passphrase is required for each operation, which is very cumbersome. In Windows, you can use Putty's pageant cache passphrase. In Windows, you can use SSH-agent and SSH-add
First, execute:
$ Ssh-agent
Then execute:
$ Ssh-add
The system will prompt you to enter passphase for the specified private key. after entering the passphase, you will not need to enter passphrase again when using subcipse for detection/entry.