【Mac + GitHub】之在另外一臺Mac電腦上下載GitHub的SSH連接報錯

當輸入git命令github項目時報錯:linux

⇒  git clone git@github.com:/TX-Class.git
Cloning 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 rights
and the repository exists.

錯誤①:git

Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.

此錯誤參考:《git提交警告Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of

hosts文件的位置:

一、Mac:/etc/hostsgithub

vim /etc/hosts

添加一行:13.250.177.223  github.comvim

可是修改完文件輸入::wq!時報錯dom

Can't open file for writingssh

解決參考:《linux操做提示:「Can't open file for writing」或「operation not permitted」的解決辦法ide

修改文件命令時,應該用sudospa

 

sudo vim /etc/hosts

 

再修改爲功!!.net

錯誤②code

fatal: Could not read from remote repository.

參考文章:《GIT 出現fatal: Could not read from remote repository.解決

 

輸入命令:

ssh-keygen -t rsa -C xxx@xxx.com

xxx@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.com
The 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 ~/.ssh

ls
# 若是有下面幾個文件就成功了
id_rsa      id_rsa.pub  known_hosts

接下來打開github官網:選擇設置

添加新的SSH key

複製新的key內容,輸入:

pbcopy < ~/.ssh/id_rsa.pub

複製完粘貼到下面如圖裏

 新的keys

最後就能夠下載github中的SSH連接的項目了:

相關文章
相關標籤/搜索