当输入git命令github项目时报错:
⇒ git clone git@github.com:/TX-Class.gitCloning into 'TX-Class'...Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.git@github.com: Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.
错误①:
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts. 此错误参考:《》
hosts文件的位置:
1、Mac:/etc/hosts
vim /etc/hosts
添加一行:13.250.177.223 github.com
但是修改完文件输入::wq!时报错
Can't open file for writing
解决参考:《》
修改文件命令时,应该用sudo
sudo vim /etc/hosts
再修改成功!!
错误②
fatal: Could not read from remote repository.
参考文章:《》
输入命令:
ssh-keygen -t rsa -C xxx@xxx.comxxx@xxx.com # 为你的github账号
一直按回车,什么都不输入。
Generating public/private rsa key pair.Enter file in which to save the key (/Users/[username]/.ssh/id_rsa):Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /Users/[username]/.ssh/id_rsa.Your public key has been saved in /Users/[username]/.ssh/id_rsa.pub.The key fingerprint is:SHA256:HyXP86ndZiNVOchlHrHMriy5SoHredqReKwESZgtZx4 xxx@xxx.comThe key's randomart image is:+---[RSA 2048]----+| ..|| + o+.|| + E . o =+o|| * o . = o.+.|| + .S.. + .o|| . +.o.oo.o || + *.o o+ || o *.. o+ oo|| =oo... ooo|+----[SHA256]-----+
再输入:
cd ~/.sshls # 如果有下面几个文件就成功了 id_rsa id_rsa.pub known_hosts
接下来打开github官网:选择设置
添加新的SSH key
复制新的key内容,输入:
pbcopy < ~/.ssh/id_rsa.pub
复制完粘贴到下面如图里
新的keys
最后就可以下载github中的SSH链接的项目了: