linux下Git的安装和配置

1.Git 安装

命令:sudo apt install git


2.查看安装的git版本

命令:git --version


3.申请 git帐号

git官网:https://github.com/


4.生成public key

命令:ssh-keygen -t rsa -C"xxx@xxx"

xxx@xxx为你的GIT邮箱。

(1)选择保存文件,我选择的是sshkey.

(2)输入两次密码,便会生成ssh key,并保存在sshkey.pub中。

Generating public/private rsa key pair.
Enter file in which to save the key (/home/lgj/.ssh/id_rsa): sshkey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in sshkey.
Your public key has been saved in sshkey.pub.
The key fingerprint is:
SHA256:Cuee16KJJvm1pGcP601sbiIFryY20MY69uG9Izwg6Ik lgj_wish@163.com
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|                 |
|    .            |
|.o  .o. S        |
|+.+  +oo         |
|+++o o* +.       |
|E+B+BB+@+ .      |
|.o.X*B@*+.       |
+----[SHA256]-----+


5.查看public key

在保存目录打开sshkey.pub文件

命令:cat sshkey.pub


6.官网登陆帐号

(1)选择 帐号-设置

(2)选择左侧SSH and GPG Keys

 (3)新建ssh key,Title随便写,复制sshkey.pub中的内容到key中。

7.测试ssh key 连接是否成功

使用命令“ssh -T git@github.com”,如果出现You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。

如果出现:Permission denied (publickey).

输入命令:ssh -T -v git@github.com

可以看到一直在寻找 这四个文件。未找到就不再寻找。

这是因为上面我们设置的key文件为sshkey sshkey.pub.

sshkey sshkey.pub.复制到.ssh中

命令:cp sshkey  ./.ssh/id_rsa

         cp sshkey.pub  ./.ssh/id_rsa.pub

再一次进行测试:cp sshkey.pub  ./.ssh/id_rsa.pub

成功显示:Hi lgjwish! You've successfully authenticated, but GitHub does not provide shell access.

如果用户创建多个KEY,将会有其他的问题,可参考其他网友的解决方案。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值