mac 配置 ssh 到git (Could not resolve hostname github.com, Failed to connect to github.com port 443 Operation timed out)


1、進入終端命令行

(1)輸入:cd .ssh/

進入到.ssh后,輸入ls,會輸出“known_hosts”,如果沒有創建過rsa的話

(2)輸入:man ssh-add

(3)輸入:ssh-keygen -t rsa -C "your email"   // 你的郵箱

(4)輸入:輸入私鑰名字

Enter file in which to save the key (/Users/lele/.ssh/id_rsa): id_rsa1  // 給生成生成私鑰命名

(5)輸入:密碼

Enter passphrase (empty for no passphrase):   // 設置輸入密碼

(6)輸入:密碼

Enter same passphrase again: 

Your identification has been saved in id_rsa1. // 私鑰文件

Your public key has been saved in id_rsa1.pub. // 公鑰文件

(7)輸入:ls

查看文件

輸出:id_rsa id_rsa1、id_rsa1.pub 、known_hosts

(8)輸入:ssh-add id_rsa1  // 添加私鑰

(9)輸入:密碼

Enter passphrase for id_rsa1: 

Identity added: id_rsa1 (id_rsa1)

2、找到ssh文件夾下的id_rsa1.pub文件。

終端命令行輸入:open ~/.ssh,打開.ssh文件夾。

找到id_rsa1.pub文件,用文本編輯器打開,復制到git的ssh上。

3、查看隱藏文件夾、文件

關閉所有finder窗口后。

終端命令行輸入以下命令:

顯示:defaults write com.apple.finder AppleShowAllFiles -bool true
隱藏:defaults write com.apple.finder AppleShowAllFiles -bool false

4、[git]ssh: Could not resolve hostname github.com: nodename nor servname provided, or not known

This sounds like a DNS issue. Try switching to another DNS server and see if it works.

OpenDNS

    208.67.222.222
    208.67.220.220

GoogleDNS

    8.8.8.8
    8.8.4.4

5、 git push 出錯:Failed to connect to github.com port 443 Operation timed out

 Mac :

(1)在Mac的“/private/etc”目錄下找到hosts文件;

具體操作:切換到Finder界面,按下“shift + Command + G”,在彈出框中輸入“/private/etc”

(2)用任意一款編輯器打開這個hosts文件;

(3)刪除關於GitHub的所有host,保存並關閉;

具體操作:hosts文件不能直接編輯,先備份,然后再復制一份到桌面,然后打開,搜索“Git”,刪除所有包括“git”的行,保存,再拖至原來的文件夾下,選擇替換。

6、 SSH 通過ssh-keygen 修改密碼

 使用ssh-keygen修改密碼:

-p 選項請求修改私鑰的密碼,而不是創建一個新的私鑰。程序會提示你輸入原始密碼。然后輸入兩遍新密碼。

-f{filename} 選項去指定密鑰的名稱

cd .ssh 目錄

ssh-keygen -f id_rsa -p  

輸入舊密碼,再輸入兩次新密碼, 提示“Your identification has been saved with the new passphrase.”


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM