如何使用公钥认证设置Maven与CVS连接?

时间:2020-12-08 23:56:21

I have a section in a POM that looks something like this:

我在POM中有一个看起来像这样的部分:

<scm>
    <connection>scm:cvs:ext:myhostname:/cvsroot/repo:module_name</connection>
</scm>

I typically use publickey auth to authentication against this cvs server, although it should accept my password as well.

我通常使用publickey auth来对这个cvs服务器进行身份验证,尽管它也应该接受我的密码。

When I attempt to run mvn scm:update, mvn release:prepare, or any other Maven goal that involves connecting to this scm, I get the following failure:

当我尝试运行mvn scm:update,mvn release:prepare或任何其他涉及连接到此scm的Maven目标时,我遇到以下故障:

[INFO] Executing: cmd.exe /X /C "cvs -z3 -f -q update -d"
[INFO] Working directory: C:\Documents and Settings\matt\workspace\projectname
org.netbeans.lib.cvsclient.connection.AuthenticationException: Cannot authenticate. Reason: Publickey authentication failed.
    at org.apache.maven.scm.provider.cvslib.cvsjava.util.ExtConnection.open(ExtConnection.java:136)
    at org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsConnection.connect(CvsConnection.java:166)
    at org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsConnection.processCommand(CvsConnection.java:498)
    at org.apache.maven.scm.provider.cvslib.cvsjava.command.update.CvsJavaUpdateCommand.executeCvsCommand(CvsJavaUpdateCommand.java:53)
    at org.apache.maven.scm.provider.cvslib.command.update.AbstractCvsUpdateCommand.executeUpdateCommand(AbstractCvsUpdateCommand.java:78)
    at org.apache.maven.scm.command.update.AbstractUpdateCommand.executeCommand(AbstractUpdateCommand.java:63)
    at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:59)
    at org.apache.maven.scm.provider.cvslib.AbstractCvsScmProvider.executeCommand(AbstractCvsScmProvider.java:750)
    at org.apache.maven.scm.provider.cvslib.AbstractCvsScmProvider.update(AbstractCvsScmProvider.java:348)
    at org.apache.maven.scm.provider.AbstractScmProvider.update(AbstractScmProvider.java:821)
    at org.apache.maven.scm.provider.AbstractScmProvider.update(AbstractScmProvider.java:770)
    at org.apache.maven.scm.manager.AbstractScmManager.update(AbstractScmManager.java:526)
    at org.apache.maven.scm.plugin.UpdateMojo.execute(UpdateMojo.java:89)

(lots more of the stacktrace....)

(更多的堆栈跟踪....)

And further down in the stacktrace:

并进一步在堆栈跟踪中:

Caused by: java.io.IOException: Decrypted PEM has wrong padding, did you specify the correct password?
    at ch.ethz.ssh2.crypto.PEMDecoder.removePadding(PEMDecoder.java:109)
    at ch.ethz.ssh2.crypto.PEMDecoder.decryptPEM(PEMDecoder.java:286)
    at ch.ethz.ssh2.crypto.PEMDecoder.decode(PEMDecoder.java:319)

Followed by:

[ERROR] Provider message:
[ERROR] The cvs command failed.
[ERROR] Command output:

I'm running this on a Windows machine, with no cvs executable on the PATH. I do have my public key available under $HOME/.ssh, but it doesn't seem as if cvs/maven/scm is loading it here - as I'm not asked for the keyphrase for it.

我在Windows机器上运行它,在PATH上没有可执行的cvs。我确实在$ HOME / .ssh下提供了我的公钥,但似乎cvs / maven / scm似乎没有在这里加载它 - 因为我没有被要求提供密钥短语。

So my question is ... is there anything special I need to do with Maven or the SCM/CVS provider to get it to recognize where my public key is installed, or how to actually use it? Currently it doesn't seem as if it is even being used as I am not prompted for it's passphrase.

所以我的问题是......我需要对Maven或SCM / CVS提供商做些什么特别的事情来让它识别我的公钥安装位置,或者如何实际使用它?目前似乎它甚至没有被使用,因为我没有被提示它的密码短语。

2 个解决方案

#1


So after debugging this a bit more, and downloading the source code for the maven-scm-provider-cvs package, I discovered that the CVS library used by this plugin uses the empty string ("") for the passphrase value if it finds your private key. To use the correct passphrase, the library expects you to set a System property with the key name maven.scm.cvs.java.ssh.passphrase.

所以在调试了这一点之后,并下载了maven-scm-provider-cvs包的源代码,我发现这个插件使用的CVS库使用空字符串(“”)作为密码短语值,如果它找到你的私钥。要使用正确的密码,库需要您使用密钥名称maven.scm.cvs.java.ssh.passphrase设置System属性。

So, if I run my scm:status goal like so:

所以,如果我像这样运行我的scm:status目标:

mvn scm:status -Dmaven.scm.cvs.java.ssh.passphrase=<my passphrase>

I'm able to connect to CVS.

我能够连接到CVS。

Gee - I really wish this was documented!

哎呀 - 我真的希望这是有记录的!

#2


I solved this by executing the cvs+ssh login command from the console before using maven. This added the magic numbers to $home/.ssh for the automated login to work.

我在使用maven之前通过从控制台执行cvs + ssh login命令解决了这个问题。这为$ home / .ssh添加了神奇的数字,以便自动登录工作。

If this is because of a self-signed cert, check out the InstallCert code on how to add the self signed cert to the client. Or this example on how to replace the default X509 Trust code.

如果这是因为自签名证书,请查看InstallCert代码,了解如何将自签名证书添加到客户端。或者这个例子介绍了如何替换默认的X509 Trust代码。

#1


So after debugging this a bit more, and downloading the source code for the maven-scm-provider-cvs package, I discovered that the CVS library used by this plugin uses the empty string ("") for the passphrase value if it finds your private key. To use the correct passphrase, the library expects you to set a System property with the key name maven.scm.cvs.java.ssh.passphrase.

所以在调试了这一点之后,并下载了maven-scm-provider-cvs包的源代码,我发现这个插件使用的CVS库使用空字符串(“”)作为密码短语值,如果它找到你的私钥。要使用正确的密码,库需要您使用密钥名称maven.scm.cvs.java.ssh.passphrase设置System属性。

So, if I run my scm:status goal like so:

所以,如果我像这样运行我的scm:status目标:

mvn scm:status -Dmaven.scm.cvs.java.ssh.passphrase=<my passphrase>

I'm able to connect to CVS.

我能够连接到CVS。

Gee - I really wish this was documented!

哎呀 - 我真的希望这是有记录的!

#2


I solved this by executing the cvs+ssh login command from the console before using maven. This added the magic numbers to $home/.ssh for the automated login to work.

我在使用maven之前通过从控制台执行cvs + ssh login命令解决了这个问题。这为$ home / .ssh添加了神奇的数字,以便自动登录工作。

If this is because of a self-signed cert, check out the InstallCert code on how to add the self signed cert to the client. Or this example on how to replace the default X509 Trust code.

如果这是因为自签名证书,请查看InstallCert代码,了解如何将自签名证书添加到客户端。或者这个例子介绍了如何替换默认的X509 Trust代码。