V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
higocn
V2EX  ›  git

本地配置两个 github 账户,其中一个正常,一个有问题,求教?

  •  
  •   higocn · 2016-09-27 22:45:38 +08:00 · 2529 次点击
    这是一个创建于 2983 天前的主题,其中的信息可能已经有所发展或是发生改变。
    其中有问题的账户:
    1. 公匙已正确添加, htts 可以访问;
    2. 连接报错

    ···
    ssh_exchange_identification: Connection closed by remote host
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    ···

    3. ssh [email protected] -vT 测试有问题的输出:

    ···
    OpenSSH_6.9p1, LibreSSL 2.1.8
    debug1: Reading configuration data /Users/hzchen/.ssh/config
    debug1: /Users/hzchen/.ssh/config line 7: Applying options for github.com
    debug1: /Users/hzchen/.ssh/config line 13: Applying options for *
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 20: Applying options for *
    debug1: /etc/ssh/ssh_config line 102: Applying options for *
    debug1: Connecting to github.com [192.30.253.112] port 22.
    debug1: Connection established.
    debug1: identity file /Users/hzchen/.ssh/id_rsa type 1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/hzchen/.ssh/id_rsa-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.9
    ssh_exchange_identification: Connection closed by remote host
    ···
    7 条回复    2016-09-30 14:30:00 +08:00
    Dashit
        1
    Dashit  
       2016-09-28 09:24:05 +08:00
    config 文件贴了看下。
    higocn
        2
    higocn  
    OP
       2016-09-28 10:03:23 +08:00
    @Dashit config
    Host git.mydomain.com
    Port 65422
    HostName git.mydomain.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/aaa_rsa

    Host github.com
    HostName github.com
    User myname
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa

    Host *
    IdentitiesOnly yes

    我发现在公司两个都可以访问,在家就只有上边那个可以访问。
    Dashit
        3
    Dashit  
       2016-09-28 10:31:39 +08:00
    @higocn 我也是用这种方法弄的。看日志像是 ssh key 的问题。 wifi 情况生成的 ssh key 连网线是不能用的。没有这种情况吧。
    higocn
        4
    higocn  
    OP
       2016-09-28 11:11:18 +08:00
    @Dashit
    我都是 wifi 生成的, key 应该没问题, 因为在公司网,两个都是正常访问的。只有在家里,是底下那个不能访问。
    iCyMind
        5
    iCyMind  
       2016-09-28 11:12:10 +08:00
    把私钥文件名改回 id_rsa 试试。
    Tip: On most systems the default private keys (~/.ssh/id_rsa, ~/.ssh/id_dsa and ~/.ssh/identity) are automatically added to the SSH authentication agent. You shouldn't need to run ssh-add path/to/key unless you override the file name when you generate a key.

    https://help.github.com/articles/error-permission-denied-publickey/#make-sure-you-have-a-key-that-is-being-used
    higocn
        6
    higocn  
    OP
       2016-09-28 13:59:34 +08:00
    @iCyMind 就是那个 id 的有问题, aaa 的都好着
    iCyMind
        7
    iCyMind  
       2016-09-30 14:30:00 +08:00
    @higocn github 那个用户名, 请改为 git
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5441 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 07:29 · PVG 15:29 · LAX 23:29 · JFK 02:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.