Maven 发布插件:权限被拒绝(公钥)Github
Maven Release Plugin: Permission denied (publickey) Github
我正在尝试部署托管在 Github 上的 Maven 项目。我已经生成 public 密钥并将其添加到 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 密钥有问题:
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。
您在 URL:
中使用了错误的 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 密钥才会被使用。
确保如果您正在使用配置文件,请在 mvn 的参数中指定 -P release:command
我正在尝试部署托管在 Github 上的 Maven 项目。我已经生成 public 密钥并将其添加到 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 密钥有问题:
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。
您在 URL:
中使用了错误的 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 密钥才会被使用。
确保如果您正在使用配置文件,请在 mvn 的参数中指定 -P release:command