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

求助,github 已经配置好 ssh,但是提示输入密码

  •  
  •   luvxy · 2022-09-21 16:38:21 +08:00 · 2127 次点击
    这是一个创建于 554 天前的主题,其中的信息可能已经有所发展或是发生改变。

    之前用的好好的,包括我其他 git 平台 ssh 都是正常使用,只有 github 不行. 尝试删除.ssh 里所有文件 重新生成 ssh key,重新上传 github 还是不行,其他 git 平台上传后就正常使用了 现在是我自己 github 仓库代码都没拉取了. 执行

    ssh -vT [email protected]
    

    结果

    ssh -vT [email protected]
    OpenSSH_8.6p1, LibreSSL 3.3.5
    debug1: Reading configuration data /Users/dzjhack/.ssh/config
    debug1: /Users/dzjhack/.ssh/config line 1: Applying options for *
    /Users/dzjhack/.ssh/config line 4: Unsupported option "rsaauthentication"
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
    debug1: /etc/ssh/ssh_config line 54: Applying options for *
    debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
    debug1: Connecting to github.com port 22.
    debug1: Connection established.
    debug1: identity file /Users/dzjhack/.ssh/id_rsa type 0
    debug1: identity file /Users/dzjhack/.ssh/id_rsa-cert type -1
    debug1: Local version string SSH-2.0-OpenSSH_8.6
    debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6
    debug1: compat_banner: match: OpenSSH_7.6 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
    debug1: Authenticating to github.com:22 as 'git'
    debug1: load_hostkeys: fopen /Users/dzjhack/.ssh/known_hosts2: No such file or directory
    debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
    debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: algorithm: curve25519-sha256
    debug1: kex: host key algorithm: rsa-sha2-512
    debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
    debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: SSH2_MSG_KEX_ECDH_REPLY received
    debug1: Server host key: ssh-rsa SHA256:rEmlJenVMSL5GVemSY0Gk8WGw6B4ege4J85M+vup8R0
    debug1: load_hostkeys: fopen /Users/dzjhack/.ssh/known_hosts2: No such file or directory
    debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
    debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
    debug1: Host 'github.com' is known and matches the RSA host key.
    debug1: Found key in /Users/dzjhack/.ssh/known_hosts:1
    debug1: rekey out after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: rekey in after 134217728 blocks
    debug1: Will attempt key: /Users/dzjhack/.ssh/id_rsa RSA SHA256:s/fI1dGa0oTc+khA0wJkPDSqJ5zOjQgBfmeP2DObn3Y explicit agent
    debug1: SSH2_MSG_EXT_INFO received
    debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss>
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey,password,keyboard-interactive
    debug1: Next authentication method: publickey
    debug1: Offering public key: /Users/dzjhack/.ssh/id_rsa RSA SHA256:s/fI1dGa0oTc+khA0wJkPDSqJ5zOjQgBfmeP2DObn3Y explicit agent
    debug1: Authentications that can continue: publickey,password,keyboard-interactive
    debug1: Next authentication method: keyboard-interactive
    debug1: Authentications that can continue: publickey,password,keyboard-interactive
    debug1: Next authentication method: password
    [email protected]'s password:
    debug1: Authentications that can continue: publickey,password,keyboard-interactive
    Permission denied, please try again.
    [email protected]'s password:
    
    第 1 条附言  ·  2022-09-21 18:16:11 +08:00

    解决了 host 里面配上 140.82.114.4 github.com,然后删掉.ssh下面的known_hosts文件,我今天最初发现的报错就是如下报错,然后我就做了重新生成ssh操作,谢谢各位,还有评论区有位兄弟说是湖北电信dns劫持问题,我觉得可信,我就是湖北电信

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
    Someone could be eavesdropping on you right now (man-in-the-middle attack)!
    It is also possible that a host key has just been changed.
    The fingerprint for the RSA key sent by the remote host is
    SHA256:rEmlJenVMSL5GVemSY0Gk8WGw6B4ege4J85M+vup8R0.
    Please contact your system administrator.
    Add correct host key in /Users/dzjhack/.ssh/known_hosts to get rid of this message.
    Offending ECDSA key in /Users/dzjhack/.ssh/known_hosts:3
    Host key for github.com has changed and you have requested strict checking.
    Host key verification failed.
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
    第 2 条附言  ·  2022-10-12 15:47:52 +08:00
    现在我又去路由里面改了 dns ,这样是最简单的解决办法,而且同事的都好了
    17 条回复    2023-01-17 22:31:08 +08:00
    luvxy
        1
    luvxy  
    OP
       2022-09-21 16:39:20 +08:00
    最后要我输入密码 怎么输入都是报 Permission denied, please try again.
    haolongsun
        2
    haolongsun  
       2022-09-21 16:58:07 +08:00
    github 有自己的 cli 验证,https://cli.github.com/ ,建议用这个验证。
    EZ4ZZW
        3
    EZ4ZZW  
       2022-09-21 17:10:54 +08:00
    我猜是 macOS Monterey Beta 版出现的问题🤔要是临时用的话可以 git remote add https ______https__repo__url 然后直接 git push https 上传,目前还没解决这个问题
    luvxy
        4
    luvxy  
    OP
       2022-09-21 17:20:38 +08:00
    @EZ4ZZW 不是这个问题, 我执行的是 ssh -vT [email protected] 。还没有去拉仓库代码 ,不过这两方式结果一样
    EZ4ZZW
        5
    EZ4ZZW  
       2022-09-21 17:49:13 +08:00
    @luvxy 我刚才找到了一个解决方案,把 ssh 改成 ssh over https ,可以解决这个问题,但是还没发现实质问题在哪里。https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port
    jinqzzz
        6
    jinqzzz  
       2022-09-21 17:51:42 +08:00
    你试试解决一开始的报错

    debug1: Reading configuration data /Users/dzjhack/.ssh/config
    debug1: /Users/dzjhack/.ssh/config line 1: Applying options for *
    /Users/dzjhack/.ssh/config line 4: Unsupported option "rsaauthentication"
    Pythondr
        7
    Pythondr  
       2022-09-21 17:56:26 +08:00
    luvxy
        8
    luvxy  
    OP
       2022-09-21 18:08:41 +08:00   ❤️ 1
    解决了 host 里面配上 140.82.114.4 github.com
    IvanLi127
        9
    IvanLi127  
       2022-09-21 18:09:47 +08:00
    [GitHub's SSH key fingerprints - GitHub Docs]( https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints)

    我草率地看了下,大概是因为你连到的服务器不是 GIthub 的。可能被劫持了。

    我用你执行的命令试了下,其中这行你的和我的不一样:

    ```
    debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
    ```

    建议重新生成一次密钥对。。。然后执行:

    ```
    ssh-keygen -R github.com
    ```

    看清楚服务器指纹是否正确,正确了同意连接。
    thefck
        10
    thefck  
       2022-09-21 18:11:37 +08:00
    > Server host key: ssh-rsa SHA256:rEmlJenVMSL5GVemSY0Gk8WGw6B4ege4J85M+vup8R0
    和我昨天遇到的情况一模一样,连这个都一样。
    改了下 github 的 hosts 就可以了。
    湖北?今天在 v2 看到说湖北电信 github 的 dns 被污染了,不知道是否有关系
    luvxy
        11
    luvxy  
    OP
       2022-09-21 18:12:59 +08:00
    @thefck 是湖北电信。我擦 我也就是改 hosts 好了
    hxy100
        12
    hxy100  
       2022-09-21 18:17:37 +08:00
    国内运营商连 Github 都要污染吗?本人 Github 相关域名常年走软路由,居然没有发现问题~
    ncepuzs
        13
    ncepuzs  
       2022-09-21 18:22:12 +08:00
    ~/.ssh/config Windows 下

    Host github.com
    HostName ssh.github.com
    Port 443
    User git
    ProxyCommand connect -S 127.0.0.1:1080 -a none %h %p

    Host *
    IdentityFile "C:\Users\<user>\.ssh\id_rsa"
    ServerAliveInterval 30
    TCPKeepAlive yes
    ganymede
        14
    ganymede  
       2022-09-24 15:33:38 +08:00
    湖北移动也碰到这个问题了,用了楼主该 hosts 方式解决了
    HuangLibo
        15
    HuangLibo  
       2022-10-05 17:26:51 +08:00
    湖北联通也遇到了这个问题,我是通过把默认 DNS 改成 114DNS 解决的。楼上说的改 host 应该也是可以的,一样的原理,DNS 被运营商劫持了。
    Zhuxb
        16
    Zhuxb  
       2022-10-11 10:21:03 +08:00
    我也是湖北电信,昨天折腾了俩小时,真蛋疼
    asanelder
        17
    asanelder  
       2023-01-17 22:31:08 +08:00
    同湖北电信, 俺最近几天也遇到这个问题了

    SHA256:rEmlJenVMSL5GVemSY0Gk8WGw6B4ege4J85M+vup8R0 这个 fingerprint 有问题, 不属于 https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints 中列举的.
    应该是 dns 污染了
    修改 host 的方法好使
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1702 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 16:44 · PVG 00:44 · LAX 09:44 · JFK 12:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.