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)
终端命令行输入: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.”