github使用ssh key认证失败

在使用composer安装依赖时报如下错误:

Executing command (CWD): git config github.accesstoken
Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
Executing command (CWD): hostname
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+hostname+2020-06-22+2236
to retrieve a token. It will be stored in "/var/www/.composer/auth.json" for future use by Composer.

这是github使用ssh key认证失败了,要使用Composer从github复制文件,需要使用上面的链接来重新获取一个token.

使用浏览器打开上面的链接,点击Generate token按钮,会生成一个40个字符长的字符串,这就是所谓的token了。

复制这个token,并把它放保存在用户目录下的.composer/auth.json文件里,格式如下:

"github-oauth":{
    "github.com":"abcde8689a77782f0de23a80b6c2dd4921656ce2"},

或者直接使用如下命令:

composer config --global --auth github-oauth.github.com abcde8689a77782f0de23a80b6c2dd4921656ce2

这样就可以重新运行composer了。

posted @ 2022-04-27 11:01  dreamboycx  阅读(464)  评论(0编辑  收藏  举报