no

Permission Denied when Running Maven Release

When releasing a maven artifact into GitHub or the central repository you encountered the infamous Permission denied (publickey) error.

1. Maven

Maven is a build-automation tools primarily built for Java. It is also use in tagging a version in Git and releasing a version in Central repository.

2. Prepare your Project for Maven Release

Prepare the pom file of your project similar to this one: https://github.com/czetsuya/ct-services-jwt-security/blob/main/pom.xml.

3. Releasing your Project

To create a tag of your project, we need to execute the maven instruction below:

mvn release:prepare release:perform

It should ask about the version that you would like to release and the next snapshot version

4. The Problem

If you are lucky, you will get the error below:

nable to commit files
Provider message:
The git-push command failed.
Command output:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

I'm sure you already check your id_rsa private and public files and is now confused why you have this problem.

5. The Solution

To fix this issue we must add our ssh private key to ssh authentication agent using the command below

ssh-add id_rsa

id_rsa is your private file that should exists in $HOME/.ssh folder.

After this you can execute the release command in step 3.

To run ssh-add in Windows you need to install Git and run GitBash console.

6. Recommendation

But in my experience, if you are running in Windows, you could avoid a lot of problems if you would use the https protocol. Instead of scm:git:git@github.com:account/repository.git, use scm:git:https://git@github.com/account/repository.git as connection and developerConnection value.

On the other hand, there shouldn't be any problem on Mac and Ubuntu machines.

Related

maven 5795896326202813918

Post a Comment Default Comments

item