Ali cloud and add SSH Key Configuration Key Git under Windows environment

1. Run the git-bash.exe enter the command line

2. Determine if the existing local public key:

cat ~/.ssh/id_rsa.pub

  If you see the continuous line in ssh-rsa beginning of the string or ssh-dsa, ssh-keygen step can be skipped

3. Generate ssh key

keygen-SSH -t RSA " Custom Identifier "

  Step two generated code will be prompted for the password (default no password), the file name and the holding Pub path, and press Enter to skip the step of using default values. Note that, if the custom filename / path needs to be done to configure the SSH client (step 5 Introduction).

  Use the following command or your generated public key:

CAT ~ /. SSH /id_rsa.pub (or your custom directory / file name)

4. Copy the public key to the personal settings aliyun SSH / My SSH Keys, different systems copy command follows:

  Windows:

Clip <~ /. SSH /id_rsa.pub (or your custom directory / file name)

  Mac:

pbcopy < ~/.ssh/id_rsa.pub

  GUN/Linux(requires xclip):

xclip -sel clip < ~/.ssh/id_rsa.pub

5. If you use a non-default location / filename stored ssh key, you must configure the SSH client to find your private key to take the link code server, it is usually ~ / .ssh / config configuration

1 # git bash executed under, create and modify config file 
2 Touch
~ /. SSH / config

  Adding follows config:

1  # Our Company's Internal gitlab Server
 2 Host my-git.company.com 3 RSAAuthentication yes4 IdentityFile ~ /. SSH / id_rsa (or your custom directory & filename)

Under some configurations 6. Git

  a. generating a plurality ssh key

    Repeat steps 3 to generate a plurality of ssh key, and a custom name / path to save

  b. manage multiple ssh key

    Run ssh-agent command to add the private key:

1 ssh-add ~/.ssh/id_rsa_gitlab
2 ssh-add ~/.ssh/id_rsa_github

    If you execute the above command appears Could not open a connection to your authentication agent, the solution is as follows:

1 # kill ssh-agent thread
 2  PS the AUX | grep  SSH 
3  the kill - 9 numbers of the threads
 4  
5 # to enter the user name of the directory. SSH directory, open the git bash execute the following command:
 6 Exec ssh-agent bash
 7 eval SSH- Agent - S
 . 8  
. 9 # then execute ssh-add command
 10  ssh-add ./ id_rsa_gitlab
 . 11  ssh-add ./id_rsa_github

  c. Create and modify the config configuration file

 1 # gitlab
 2 Host gitool.glanway.com
 3 HostName gitool.glanway.com
 4 PreferredAuthentications publickey
 5 IdentityFile ~/.ssh/id_rsa_gitlab
 6 User your-username
 7 
 8 # github
 9 Host github.com
10 HostName github.com
11 PreferredAuthentications publickey
12 IdentityFile ~/.ssh/id_rsa_github
13 User your-username

 

 

Reference article:

  https://code.aliyun.com/help/ssh/README  Ali cloud help documentation

  https://www.cnblogs.com/mingyue5826/p/11141324.html  Git install and configure SSH Key

Guess you like

Origin www.cnblogs.com/tarencez/p/12387348.html