Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1821|回复: 0
打印 上一主题 下一主题

ubuntu下配置github

[复制链接]

55

主题

78

帖子

289

积分

认证用户组

Rank: 5Rank: 5

积分
289
跳转到指定楼层
楼主
发表于 2017-3-22 15:01:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1.
打开git bash,输入命令ls -al ~/.ssh
检查是否显示有id_rsa.pub或者id_dsa.pub存在,如果存在请直接跳至第3步。


2. 切换到~/.ssh目录下,生成对应的key文件
在git bash中键入ssh-keygen -t rsa -C "your_email@example.com" -f "id_rsa_git",注意将这里的邮箱地址替换成你自己的邮箱地址。

3.查看pub文件中的内容 cat id_rsa_git.pub
复制里面的内内容到 github的账户(SSH key标签)

4.
在.ssh/下创建config文件 内容如下:
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host my.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/my
Host名字随意,接下来会用到。

原来的内容

Host *
    KexAlgorithms +diffie-hellman-group1-sha1
       
5.测试配置是否正确
ssh -T git@github.com
ssh -T git@my.github.com

如果出现Hi xxx!You've successfully authenticated 就说明连接成功了

本地已经创建或已经clone到本地:

如下两种解决方法:

打开.git/config文件

#更改[remote "origin"]项中的url中的
#my.github.com 对应上面配置的host
[remote "origin"]
url = git@my.github.com:itmyline/blog.git或者在Git Bash中提交的时候修改remote

$ git remote rm origin
$ git remote add origin git@my.github.com:itmyline/blog.git2、clone仓库时对应配置host对应的账户

#my.github.com对应一个账号
git clone git@my.github.com:username/repo.git



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-5-17 21:03 , Processed in 0.053772 second(s), 19 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表