Windows电脑多个SSH Key管理.md
2024-08-30 03:39:19
笔者偏在阿里云,Github,开源中国上均存放一些私有项目代码,因此需要再Windows电脑上配置多个SSH Key
环境
- 操作系统:windows 7
- Git
提示:Git 安装后就可以使用 Git bash ,接下来的命令都在 Git bash 中输入和执行
- 注册好 Github 账号,其中 Email 为 987654321@qq.com
- 用支付宝/淘宝账号登录 https://code.aliyun.com ,在设置->个人设置页面看到邮箱为 987654321@163.com
Github
1.打开 Git bash
2.输入命令
ssh-keygen -t rsa -C "987654321@qq.com"
3.执行结果
4.拷贝公钥
- 方法一:在 Git Bash 中输入命令拷贝文件内容到剪切板:
clip < ~/.ssh/id_rsa_github.pub
- 方法二:从文件中拷贝
进入 C:\Users\{你的用户名}.ssh\ ,用记事本打开 id_rsa_github.pub,拷贝文件中所有内容
5.添加复制的公钥到 Github 中
首先,登录 https://www.github.com ,在右上角打开弹出框,选择 Settings
在 SSH and GPG keys 打开 New SSH Key
粘贴剪切板中公钥并 Add SSH Key:
6.在 .ssh 目录下创建 config 配置文件
输入以下配置信息:
# 配置github 的key
Host github.com
HostName github.com
User git
IdentityFile C:\Users\Administrator\.ssh\id_rsa_github
7.命令测试:
ssh -T git@github.com
阿里云
1.在 Git bash 输入命令
ssh-keygen -t rsa -C "987654321@163.com"
2.执行结果
3.拷贝公钥
- 方法和 Github 中相同,目标文件变为 id_rsa_aliyun_code.pub
4.新增 SSH 公钥
首先,登录 https://code.aliyun.com , 然后点击 设置
点击“增加 SSH 密钥”
新增密钥
5.编辑 config
新增以下信息
# 配置 code.aliyun 的 key
Host code.aliyun.com
HostName code.aliyun.com
User git
IdentityFile C:\Users\Administrator\.ssh\id_rsa_aliyun_code
6.测试
ssh -T git@code.aliyun.com
参考博客
最新文章
- SignalR实现网页实时聊天功能
- Http请求中请求头Content-Type 为 form-data、x-www-form-urlencoded、raw、binary的区别
- URL tailing slash
- RESTful API 设计指南【转】
- 笔记本_thinkpad_e40_FN
- VS2010 配置opencv环境
- 前端-mate讲解
- Git显示漂亮日志的小技巧
- [一波低姿势的usaco除草记]
- CentOS服务器上的 git 包版本控制
- ibv_open_device()函数
- Python/零起点(一、数字及元组)
- PCIE 2.0协议概念基本科普
- Spring框架+Struts2框架第一次整合
- Go程序语言设计 (艾伦 A. A. 多诺万 著)
- Git+Jenkins+FileGee 发布php应用
- stenciljs 学习七 路由
- UVa 12715 Watching the Kangaroo(二分)
- Django学习---原生ajax
- iOS 7 导航栏颜色设定与适配