ArticleDirectory
- Linux Configuration
- Windows Configuration
Recently, git is used, and it is inconvenient to enter the password each time. You want to use the SSH key (a mechanism similar to the-I parameter in the SSH command ). Now the problem has been solved. Here we will summarize the problem (from the beginning of the database creation) for my reference later.
Create a private Repository
Here is an example of the test1 directory:
1. Create the test1 folder
MkdirTest1cd test1
2. Git Initialization
Git init.
3. Add a file
TouchReadme.txt git Add. Git commit-M"Init"
4. Export "repository"
CD.. Git clone-- Bare test1/. Git test1.git
Generate an SSH key
Cd ~ /.SSHSsh-keygen-T rsa-B4096# Enter the file name and save it, for example, id_rsa_test1.
Import SSH key
Import the Public Key generated in the previous step to authorized_keys.CatId_rsa_test1.pub> authorized_keys
SSH access test
Copy the private key to a specific directory of another host (such as TMP) in security mode, and run the following command (192.168.1.100 is the IP address of the target host): SSH 192.168.1.100-I/tmp/id_rsa_test1
Git access test (specifying an SSH key) Linux Configuration
1. Install git (centos6 environment)
Yum install Git-y
2. Configure the config file
Cd ~ /. Add ssh/VI config as followsCode(192.168.1.100 is the IP address of the GIT server ):
Host host100 hostname192.168.1.100User Root identityfile/Tmp/id_rsa_test1
3. Git access
After the configuration is complete, use the following command to access the database without a password:
Git clone host160:/tmp/Test1.gitcd test1git pullgit push
Windows Configuration
1. Install git
URL: http://git-scm.com/downloads (My installed version is: Git-1.8.0-preview20121022, download link: http://cloud.github.com/downloads/msysgit/git/Git-1.8.0-preview20121022.exe)
TIPS: If you select the "run git and embedded UNIX tools from the Windows Command Prompt." option during installation, you can directly use git and Unix commands in the command line.
2. Configure the config file
This is similar to Linux. It is also in the ". Ssh" folder in the user directory, for example (in Windows XP ):
C: \ Documents ents and Settings \ administrator. SSH
Create a config file. Configure the host and key for other Linux operations.
3. Git access operations are the same as those in Linux.