生成ssh并配置到vscode和gitlab详细步骤
环境准备:
下载安装git和vscode,注册号gitlab、github、gitee账号(推荐使用邮箱注册,方便配置)
git下载地址:Git - Downloads
vscode下载地址:Download Visual Studio Code - Mac, Linux, Windows
gitlab地址:The most-comprehensive AI-powered DevSecOps platform
github地址:https://github.com/
gitee地址:Gitee - 基于 Git 的代码托管和研发协作平台
1、打开Git Bash
可以在开始菜单中搜索“Git Bash”并打开
2、生成SSH密钥对
把邮箱换成你自己注册git仓库时用的邮箱
ssh-keygen -t rsa -b 4096 -C "6668889999@qq.com"
中间出现提示时直接回车就行,基本不用改什么
3、 启动SSH Agent
eval $(ssh-agent -s)
执行完出现一个端口号说明没问题
4、添加SSH私钥
ssh-add ~/.ssh/id_rsa
执行成功提示
5、复制SSH公钥到剪贴板
clip < ~/.ssh/id_rsa.pub
6、在gitlab仓库配置公钥
(1)登录到你的GitLab账户。
(2)点击右上角的用户头像,选择“Edit Profile”
(3)在左侧菜单中选择“SSH Keys”
(4)在“Key”文本框中粘贴你之前复制的公钥。
(5)给这个密钥添加一个标题
(6)点击“Add key”
7、本地新建一个空文件夹,进入其中右键选择"Open Git Bash here"
8、克隆远程仓库到空文件夹
(1)复制仓库ssh地址
(2)执行克隆命令
git clone git@gitlab.com:myRepo/mycode.git