Maven 发布插件 : Permission denied (publickey) Github

标签 maven github ssh-keys maven-release-plugin

我正在尝试部署托管在 Github 上的 Maven 项目。我已经生成并添加了我的公钥到 Github,而且我想我已经填写了 pom.xml具有所有必需的属性:

<licenses>
    <license>
        <name>MIT License</name>
        <url>http://www.opensource.org/licenses/mit-license.php</url>
    </license>
</licenses>

<developers>
    <developer>
        <name>Hristo Vrigazov</name>
        <email>hvrigazov@gmail.com</email>
        <organization>Hribol</organization>
        <organizationUrl>https://github.com/hristo-vrigazov</organizationUrl>
    </developer>
</developers>

<scm>
    <connection>scm:git:git://github.com/hristo-vrigazov/bromium.git</connection>
    <developerConnection>scm:git:git://github.com/hristo-vrigazov/bromium.git</developerConnection>
    <url>https://github.com/hristo-vrigazov/bromium</url>
    <tag>com.hribol.bromium.dsl.parent-1.0.0</tag>
</scm>

我试图发布如下:
ssh-add ~/.ssh/github_rsa
ssh-add -l
mvn release:prepare release:perform -B -e | tee maven-central-deploy.log

但是,我不断从 Maven 收到此消息,表明我的 SSH key 有问题:
Provider message:
The git-push command failed.
Command output:
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:299)
at org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:247)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: 
org.apache.maven.shared.release.scm.ReleaseScmCommandException: Unable to tag SCM
Provider message:
The git-push command failed.
Command output:
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

可能是什么原因?我能够将快照部署到 Nexus。

最佳答案

你用错了protocol (the "git" one)在您的网址中:

<connection>scm:git:git://github.com/hristo-vrigazov/bromium.git</connection>

它应该使用 ssh:
<connection>scm:git:ssh://git@github.com/hristo-vrigazov/bromium.git</connection>

或者
<connection>scm:git:git@github.com:hristo-vrigazov/bromium.git</connection>

(与 developerConnection 相同)
只有这样,您的 ssh key 才会被使用。

关于Maven 发布插件 : Permission denied (publickey) Github,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47875680/

相关文章:

java - 为什么运行 mvn clean install 命令(在 Spring Boot 项目上)如果我注释掉这些方法来跳过测试,我也会遇到单元测试失败?

java - Maven 多模块不重新加载资源

image - 使用 maphilight.js 的响应式图像

Vagrant 的SSH权限

启动 jenv 后 java_home 仍然指向最新版本的 java

maven - 从 .war 文件中排除文件夹

ios - 将 Objective-C 框架添加到 Swift XCode 项目

git - Bitbucket 事件图

ssh - 使用 ansible 执行 ssh-add 会引发错误

git - 我应该在我的 ssh 公钥中使用我的个人电子邮件吗?