Git创建ssh-key

本文介绍如何在本地创建SSH Key并通过它与GitHub建立安全连接。首先详细说明了SSH Key的生成步骤,包括设置邮箱地址及选择是否设置密码等。接着介绍了如何将生成的公钥添加到GitHub账户中,以便于进行后续的代码推送操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Git创建ssh-key

远程仓库是Git的一大特色,可以分布在不停地机器上。Github可以实现在线项目的托管,Git与Github是通过SSH加密传输的,需要设置:
第一步:创建SSH Key 在用户主目录下,查看是否有.ssh目录,如果有则跳过,如果没有:打开Git Bash:$ ssh-keygen -t rsa -C "yourmail@example.com"
邮箱地址设置为自己的邮箱地址,然后一个回车,使用默认值即可,也可以设置密码;
如果顺利,可以在主目录里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,就是SSH Key的密钥对,id_sra是私密,不能泄露,id_rsa.pub是公钥;
第二步:登录GitHub,打开Accout settings,SSH Keys的页面;然后点Add SSH Key,填上任意title,在Key文本框里粘贴id_rsa.pub文件的内容;

…or create a new repository on the command line

echo "# Testing" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:silicon2016/Testing.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin git@github.com:silicon2016/Testing.git
git push -u origin master

…or import code from another repository

You can initialize this repository with code from a Subversion, Mercurial, or TFS project.

Import code
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值