About the same computer multiple SSH KEY
management
Before I configure the computer in a virtual machine homestead had id_rsa, but now because we wanted to build a blog based hexo on github, github so you need to configure the ssh key, thus creating demand requires the same machine with multiple SSH key switch.
Use of the environment
window7系统
surroundings
git软件(携带的bash终端类似linux的终端很好用建议安装)
有一个可用的github账号
Start configuration (a configuration where only a plurality of similar)
1. Mr. Cheng neededPUBLIC KEY
Open the bash
software execute the following command
ssh-keygen -t rsa
Specifies the path name of the generated key, all the way Enter to
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/lenovo/.ssh/id_rsa): /c/Users/lenovo/.ssh/id_rsa_github_hexo
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/lenovo/.ssh/id_rsa_github_hexo.
Your public key has been saved in /c/Users/lenovo/.ssh/id_rsa_github_hexo.pub.
The key fingerprint is:
SHA256:ULsfGWCKY1aJqFQ24QkUxuPu3TiBqoJHXy6mHpQ/i0k lenovo@lenovo-PC
The key's randomart image is:
+---[RSA 2048]----+
|o=o*....+ |
|.+= +o.+ o |
|o..o= o . . |
|.. + . . . o |
|. + S o |
| +.o . . . |
|+.E.*o . |
|+o.B++. |
|+o=oo. |
+----[SHA256]-----+
In this way we ~/.ssh
create two files in the path id_rsa_github_hexo
andid_rsa_github_hexo.pub
$ ll ~/.ssh
total 15
-rw-r--r-- 1 lenovo 197121 114 九月 19 14:32 config
-rw-r--r-- 1 lenovo 197121 1679 九月 17 14:58 id_rsa
-rw-r--r-- 1 lenovo 197121 398 九月 17 14:58 id_rsa.pub
-rw-r--r-- 1 lenovo 197121 1679 九月 19 14:25 id_rsa_github_hexo
-rw-r--r-- 1 lenovo 197121 398 九月 19 14:25 id_rsa_github_hexo.pub
Note that
#设置路径,如果不设置默认生成 id_rsa 和 id_rsa.pub
Enter file in which to save the key (/root/.ssh/id_rsa):/root/.ssh/id_rsa_aaa
2. Check the system ssh-key proxy, execute the following command
Run the following command to view the ssh-key agency
ssh-add -l
If the following message, indicating that there are no any key system agent
Could not open a connection to your authentication agent.
If you find the above suggest that, proceed as follows
exec ssh-agent bash
If the system already has ssh-key
proxy, execute the following command to delete
ssh-add -D
3. Add the newly created private key in .ssh directory ssh-agent
$ ssh-add ~/.ssh/id_rsa_github_hexo
# 添加成功会有如下提示
Identity added: /c/Users/lenovo/.ssh/id_rsa_github_hexo (/c/Users/lenovo/.ssh/id_rsa_github_hexo)
4. Open the ssh github management page to submit the public key corresponding to save code management server (.pub end)
Executed in a terminal
cat id_rsa_github_hexo.pub
github account click on the specific location of Settings
the SSH and FPG keys
click New SSH key
to enter their local green button id_rsa_github_hexo.pub
content
5. Create config configuration file in the .ssh directory
vim ~/.ssh/config
Enter the following configuration information (which is a single configuration, a plurality of similar)
# 配置github 的key
Host github
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_github_hexo
6. Test whether you can configure ssh access after completion github
$ ssh -T [email protected]
Hi qnyt1993! You've successfully authenticated, but GitHub does not provide shell access.
Here it has been shown that the end configuration