标签:agent private inux sha VID 查看系统 提交 终端 页面
SSH KEY
管理笔者之前为电脑中的homestead虚拟机配置过id_rsa,但现在因为想在github上搭建基于hexo的博客,所以需要配置github的ssh key,因此产生需要同一台机器上使用多个SSH key 切换的需求.
window7系统
git软件(携带的bash终端类似linux的终端很好用建议安装)
有一个可用的github账号
PUBLIC KEY
打开bash
软件执行如下命令
ssh-keygen -t rsa
指定生成key的路径名称,一路回车即可
$ 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]-----+
这样我们就在~/.ssh
路径下生成两个文件id_rsa_github_hexo
和id_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
#设置路径,如果不设置默认生成 id_rsa 和 id_rsa.pub
Enter file in which to save the key (/root/.ssh/id_rsa):/root/.ssh/id_rsa_aaa
执行如下命令查看ssh-key代理
ssh-add -l
如果如下提示,说明系统代理里没有任何key
Could not open a connection to your authentication agent.
如果发现上面的提示,,请执行如下操作
exec ssh-agent bash
如果系统已经有ssh-key
代理 ,执行下面的命令可以删除
ssh-add -D
$ 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)
在终端执行
cat id_rsa_github_hexo.pub
github具体位置在 点击账户的Settings
中的SSH and FPG keys
点击New SSH key
绿色按钮 输入自己本地id_rsa_github_hexo.pub
中的内容
vim ~/.ssh/config
输入如下配置信息(这是配置单个的,多个类似)
# 配置github 的key
Host github
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_github_hexo
$ ssh -T git@github.com
Hi qnyt1993! You've successfully authenticated, but GitHub does not provide shell access.
这里表明已经可以了,配置结束
标签:agent private inux sha VID 查看系统 提交 终端 页面
原文地址:https://www.cnblogs.com/ifme/p/11549790.html