配置SSH连接GitHub

来源:互联网 发布:分布式java应用 编辑:程序博客网 时间:2024/06/05 22:41

1、先安装ssh,一条命令搞定

$ sudo apt-get install openssh-server

2、生成秘钥

$ ssh-keygen -t rsa -C "your email"  若不需要密码,连续三次回车,在~/.ssh/目录下得到两个文件:id_rsa和id_rsa.pub。

3、登陆Github,将id_rsa.pub中的公钥内容全部复制到github上。

点击右上角账号头像的“▼”→Settings→SSH kyes→Add SSH key

4、测试

$ ssh -T git@github.com

你将会看到

The authenticity of host 'github.com (207.97.227.239)' can't be established.RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.Are you sure you want to continue connecting (yes/no)?

选择 yes后,出现

Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.

如果看到Hi后面是你的用户名,说明设置成功了。
5、添加远程仓库的ssh路径

$ git remote add ssh路径 
原创粉丝点击