mac 配置 ssh 到git (Could not resolve hostname github.com)

时间:2021-08-28 13:45:27

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