CentOS7下配置github客户端

安装基础包

直接安装tig命令,因为git是tig依赖的,所以git会被一起安装上。

 yum install tig -y

配置

执行ssh-keygen -t rsa,默认会在./root/.ssh/目录下生成id_rsa.pub公钥文件,该文件后面需要用来添加到github配置中。

[root@anonymous ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:fudmE8Vhi9Ln2kearzOaVEy90xCBGaONAx1QKAkRWhY root@anonymous
The key's randomart image is:
+---[RSA 2048]----+
|  E= . .++..o+o. |
| +  o .  ..+o.o..|
|.    .    +..+.oo|
|          ..o =+o|
|        S  . + o+|
|       .    . ..o|
|        . . .+.+ |
|         . o=.B .|
|           o..oO.|
+----[SHA256]-----+
[root@anonymous ~]# cd .ssh/
[root@anonymous .ssh]# ls
id_rsa  id_rsa.pub  known_hosts

github上配置

登录自己的github账号,单击右上角的头像->settings->SSH and GpG keys->New SSH key

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

验证配置是否成功

通过执行ssh -T git@github.com 验证前面的配置是否成功,如果看到最后面的successfully authenticated字样,表示已经配置成功。

[root@anonymous ~]# ssh -T git@github.com
The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomT3dCARLviKw6E5SX8.
RSA key fingerprint is MD5:16:27:ac:5a:76:28:2d:36:63:1b:56:3d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
Hi your_github_username! You've successfully authenticated, but GitHub does not provide shell access.
[root@anonymous ~]# ls

配置用户名和邮箱并拉取仓库测试

[root@anonymous ~]# git config --global user.name "myusername"
[root@anonymous ~]# git config --global user.email "test@gmail.com"
[root@anonymous ~]# git clone git@github.com:myusername/2021.git
Cloning into '2021'...
remote: Enumerating objects: 14, done.
remote: Total 14 (delta 0), reused 0 (delta 0), pack-reused 14
Receiving objects: 100% (14/14), 5.82 KiB | 0 bytes/s, done.
Resolving deltas: 100% (3/3), done.
You have mail in /var/spool/mail/root
[root@anonymous ~]# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值