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”的行,保存,再拖至原来的文件夹下,选择替换。