查看本机ssh 公钥

159 阅读1分钟

windows 端

如果没有公钥的话,需要生成

ssh-keygen -t rsa -C "xxx@gmail.xx"

Mac 端

cd ~/.ssh/

没有的话,需要生成

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

然后查看公钥

cat C:\Users\Administrator\.ssh\id_rsa.pub

github 添加 deploy key

如果是新建的仓库的话,需要生成新的key,

然后把 id_rsa.pub 生成的key粘贴进去,就可以用了

 

如果工作和github都需要的话,当然先保证工作,github提交代码时会出现

Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

 

这个错误,具体解决办法就是新建一个 github_id_rsa, 然后执行这个命令

ssh-add ~/.ssh/id_rsa

 

记得添加 user.name 和 user.email

git config --global user.name "xxx"

git config --global user.email "xxx@gmail.com"