A complete collection of problems and solutions encountered in git accessing github under Linux (too many, update slowly)

Table of contents

Table of contents

1. ssh -T [email protected] is configured with a public key and still prompts [email protected]'s password: Permission denied, please try again. 

 2. ssh: connect to host github.com port 22: Connection refused

 3. git报错Failed to connect to127.0.0.1 port 1080:Connection refused

4. The solution to getting stuck when git push (no error or automatic exit for a long time)_Related Skills_Network Programming-Programming Inn

5. fatal: The current branch master has no upstream branch solution_Xiaozhi's blog-CSDN blog

6. https://www.cnblogs.com/princesong/p/9885857.html

7. Security verification - Zhihu

8. 完美解决remote: Support for password authentication was removed on August 13, 2021. Please use a perso | LongSheng



        I have encountered a lot of deceptive problems, and I have consulted a large amount of information on the Internet to summarize. The relevant simplified content is as follows, and some information links will be placed below each item. I hope it can help people who are suffering like me.

        Just to mention, it is basically no problem to use git to access Github according to the blogger's big method:

Steps to use GitHub on Ubuntu_xyyshh's Blog-CSDN Blog_github ubuntu

        The following are the problems and solutions encountered:

1.   ssh -T [email protected] is configured with a public key and still prompts [email protected]'s password: Permission denied, please try again. 

        Use the ssh -Tv [email protected]  command to test the link and print the log. If there is no problem after checking, you can check whether it is a firewall problem (if you are too lazy to read, you can directly press the steps below to test the water), see below : 

Enter this command to test it. If no error is reported, it is likely to be a problem with the firewall .

ssh -T -p 443 [email protected]

Open the config file in your .ssh folder and add the following content at the bottom. If you don’t find this file in your .ssh folder, create a new one in your .ssh folder.

Host github.com
Hostname ssh.github.com
Port 443
User git

Try ssh -T [email protected] again , it will probably be ok.

For details, please see this official document  Using SSH over the HTTPS port - GitHub Docs 

A blogger's big connection: github configured the public key and still prompts [email protected]'s password: Permission denied, please try again. The solution_XeonYu's Blog-CSDN Blog

 2. ssh: connect to host github.com port 22: Connection refused

method:

(1) Use port 443 of Github

        Port 22 may be blocked by the firewall, you can try to connect to port 443 of GitHub. This solution is the same as Question 1, please refer to the steps in Question 1 for details.

        Again, the prerequisite for this solution to be effective is that ssh -T -p 443 [email protected]there will be no prompts after executing the command connection refused, so those who want to try this solution should first execute this command to test it.

(2) Use https protocol instead of ssh protocol

In your GitHub local repo directory , execute:

$ git config --local -e

Then change the url configuration item inside from git format to https format

put url = [email protected]:username/repo.git

Change to url = https://github.com/username/repo.git

 This method actually modifies the ./git/config  file in the repo and directory

(3) Modify DNS

If none of the above methods work, there is another method (this method also saved my life):

Use ssh -vthe command to print detailed logs.

I found that the address to connect to http://github.com is actually ::1and 127.0.0.1. The former is the localhost address of IPV6, and the latter is the localhost address of IPV4. At this point, the problem is very clear. There is a problem with the DNS resolution . As a result, the domain name of http://github.com is resolved to the ip address of localhost, and it is naturally impossible to connect to GitHub.

This problem is that the DNS resolution is polluted. There are two possibilities:

  • DNS resolution is hijacked by the operator
  • Science Internet Tool

Solution:

①Clear DNS cache

② Modify the hosts file and add a github.com domain name mapping at the bottom:

vim /etc/hosts //Edit this file

Add 140.82.113.4 github.com at the bottom of the hosts file //See below for how to find this ip address

Press Esc, and then enter: wq! Save and exit

If permissions are insufficient:

sudo su has root privileges, and then perform the above operations

After the operation, the terminal enters exit to exit

To find the ip address of github.com, you can use https://www.ipaddress.com/ to query, or you can use nslookupthe command

nslookup github.com 8.8.8.8 //8.8.8.8 is the DNS server address of Google, if not added, it will use the DNS server already set on this machine for domain name resolution.
ipconfig /all You can view the local DNS server address.

 3. git报错Failed to connect to127.0.0.1 port 1080:Connection refused

Solution:

(1) Removal of agency

        Many people on the Internet use this method to solve it, but this method is useless to me, I am a bit lazy, so I will not release it here, family members who need it, please check it online.

(2) Modify the .gitconfig file

Enter the user's root directory

cd or cd ~

 Modify the content of .gitconfig

vim .gitconfig

Delete those http_proxy, ftp_proxy, all_proxy, https_proxy, no_proxy pointing to 127.0.0.1:1080.

Press Esc, and then enter: wq! Save and exit

        When reporting a connection rejection error, first determine whether there are some proxies on your own host or the proxies that were previously set up because you want to speed up access. If so, try deleting them first. If this is still the case, see if others can connect. If Others can't connect, so it may be a problem with the git service

4.   The solution to getting stuck when git push (no error or automatic exit for a long time)_Related Skills_Network Programming-Programming Inn

5.  fatal: The current branch master has no upstream branch solution_Xiaozhi's blog-CSDN blog

6. https://www.cnblogs.com/princesong/p/9885857.html

7.  Security Verification - Zhihu

8. 完美解决remote: Support for password authentication was removed on August 13, 2021. Please use a perso | LongSheng

Plus a summary: security verification - know almost

おすすめ

転載: blog.csdn.net/qq_51368339/article/details/127889467