一台电脑,连两个github

原来有一个,再添一个时出错,于是乎,卸载重装,重新配置。

sudo apt remove git                   # 卸载
sudo apt-get install git                  # 重装
cd z
cd .ssh
.ssh ll
ssh-keygen -t rsa -C "1。。。@qq.com"        #  创建密匙 , 第一个的
gedit z.pub                      #  打开这个,粘贴到github
ssh -T git@github.com  # 测试  Hi ab! You've successfully authenticated, but GitHub does not provide shell access. 测试出现这个就差不多了成功了
ssh-add ~/.ssh/z     # 加上
touch config       # 创建配置文件。  文件在下面。
gedit config       # 打开并编辑。
ssh -T git@z.com          #  @后面 写的东西,就是config中Host的字。 这个字会被自动识别替换,
ssh-keygen -t rsa -C "1。。。。。@qq.com"    # 弄另一个私事匙
ssh -T git@X.com             # 测试 测试结果应该除名字外同上
ssh-add ~/.ssh/X
cd z
ls
cd a
git clone git@github.com:a/temp.git     # 这句也行,
cd temp
touch ap.py
ls
git  status
git add ap.py
git status
git commit -m "hap"
git status
git pull    # 成功
git push             # 成功
# config 文件的内容。

Host z.com     #  ssh -T 这个测试时用HOST ....git@z.com...
HostName github.com     # 一般都折磨写
PreferredAuthentications publickey  # 不知道干嘛用的,不过这么写应该是对的
IdentityFile ~/.ssh/z    # 这个用户的Private Key 在哪,  如下 在命令行中:
              (base)zheng@z:~/zheng/ab/temp$ ssh-keygen -t rsa -C "ha0.com"
              Generating public/private rsa key pair.
              Enter file in which to save the key (/home/zheng/.ssh/id_rsa): 
              。
              在冒号后面可以输入路径,最好默认在 .ssh/下, ,然后生层rsa文件
              这步生成的文件在哪, 叫啥, IdentityFile 后面的路径就写啥

Host X.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/X
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值