MAC Coding,github 账号管理问题

场景

由于在 coding 和 github 上面都托管着项目,在实际应用中不想每次进行代码提交和代码拉取时输入账号密码,但由于git 上面和coding的账号不一致,导致配置完一个,另一个平台的账号就无法使用的情况。

解决方案

  1. 生成签名
  2. 修改 ssh_config (mac 的位置:/etc/ssh/ssh_config)
  3. 添加签名 ssh-add
  4. 测试配置结果

生成签名

ssh-keygen -t rsa -C "coding"
ssh-keygen -t rsa -C "github"

修改ssh_config

Host github
 Hostname github.com
 Port 22
 User yyy
 IdentityFile /Users/xxx/.ssh/github_yyy

Host coding
 Hostname coding.net
 Port 22
 User xxx
 IdentityFile /Users/xxx/.ssh/coding_xxx

添加签名

ssh-add /Users/xxx/.ssh/github_yyy
ssh-add /Users/xxx/.ssh/coding_xxx

测试配置结果

ssh -T git@github.com
Hi yyy! You've successfully authenticated, but GitHub does not provide shell access.

ssh -T git@git.coding.net
Hello xxx! You've connected to Coding.net via SSH successfully!

常见问题:
1、修改 http 请求为 ssh

➜  laravel_exam git:(master) git push origin master
remote: Permission to xxx/laravel_exam.git denied to XXX.
[core]
fatal: unable to access 'https://github.com/xxx/laravel_exam.git/': The requested URL returned error: 403
➜  laravel_exam git:(master) ssh -T git@github.com
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.
➜  laravel_exam git:(master) git remote -v
origin  https://github.com/xxx/laravel_exam.git (fetch)
origin  https://github.com/xxx/laravel_exam.git (push)

➜  laravel_exam git:(master) git remote set-url origin git@github.com:xxx/laravel_exam.git

➜  laravel_exam git:(master) git remote -v
origin  git@github.com:xxx/laravel_exam.git (fetch)
origin  git@github.com:xxx/laravel_exam.git (push)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值