github拉代码出现Permission denied (publickey).等问题的解决

来源:互联网 发布:网络发帖百度百科 编辑:程序博客网 时间:2024/05/18 05:06

这几天,调试串口需要使用到git hub开源的android-serialport-api网址为https://github.com/cepr/android-serialport-api

再使用github拉取代码,将遇到到问题记录,方便自己以后查阅。

1 使用https

git clone https://github.com/cepr/android-serialport-api.git
出现问题如下

ubuntu:/work2/opt/test$ git clone https://github.com/cepr/android-serialport-api.gitCloning into 'android-serialport-api'...error: gnutls_handshake() failed: A TLS packet with unexpected length was received. while accessing https://github.com/cepr/android-serialport-api.git/info/refsfatal: HTTP request failed
解决方法

出现这类错误,一般是因为自己的机器没有联网导致,连上网之后,就可以git clone。

2 使用ssh

git clone git@github.com:cepr/android-serialport-api.git

出现问题如下

ubuntu:/work2/opt/test$ git clone git@github.com:cepr/android-serialport-api.gitCloning into 'android-serialport-api'...Write failed: Connection reset by peerfatal: The remote end hung up unexpectedly
原因:没有上传public key或者上传的public key过期
解决办法:上传public key

(1)查看自己机器的public key

cat ~/.ssh/id_rsa.pub

cat后出出现一堆字符串

(2)登录github,点击github的右上角 View profile and more


(3)点击SSH and GPG keys,然后点击右上角的New SSH key,将1步骤的一大堆字符串拷贝进去就可以了


阅读全文
0 0