Ubuntu上安装git及配置ssh

Ubuntu下安装git

安装步骤:

① 安装git

sudo apt-get install git

② 1.首先设定git仓库的本地全局管理者

git config --global user.nam "syz"

git config --global user.email "247179876@qq.com"

③ 检测是否可以连接到github

ssh -T git@github.com

如果出现

1
2
3
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.229.188.59' (RSA) to the list of known hosts.
Permission denied (publickey).

这说明可以连接到github

④ 安装SSH keys
首先查看是否已经存在keys
cd ~/.ssh

ls

如果没有安装,则会没有id_rsa(私钥)和id_rsa.pub(公钥)这两个文件,接下来安装ssh keys

ssh-keygen -t rsa -C "自己的github对应的邮箱地址"

⑤ 安装成功后,可以ls看到目录下id_rsa(私钥)和id_rsa.pub(公钥)这两个文件,然后进入github(如果没有就自己创一个)添加公钥,打开自己的Github首页,点击设置->SSH and GPG Keys->new SSH key进行添加即可。

⑥ 重新测试

ssh -T git@github.com

如果成功,可以看到如下结果:

Hi 这里是你的用户名! You've successfully authenticated, but GitHub does not provide shell access.

以上就是在Ubuntu上安装git的详细教程,谢谢浏览!