2

I want to configure my Maven settings.xml to contain the RSA fingerprint of our internal repository (with id "internal"). I found an answer on how to ignore the fingerprint and found a class called SingleKnownHost in that same package which says "Simple KnownHostsProvider with known wired values" which sounds exactly like what I want, however this configuration:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd
    ">
    <!-- http://maven.apache.org/settings.html -->
    <pluginGroups/>
    <servers>
        <server>
            <id>internal</id>
            <username>root</username>
            <password>p4ssw0rd</password>
            <configuration>
                <knownHostsProvider implementation="org.apache.maven.wagon.providers.ssh.knownhost.SingleKnownHostProvider">
                    <hostKeyChecking>yes</hostKeyChecking>
                    <key>81:66:27:b9:15:36:3a:91:ec:66:43:4f:69:a0:ef:c4:b9:15:36</key>
                </knownHostsProvider>
            </configuration>
        </server>
    </servers>      
</settings>

but I get the error:

[WARNING] Could not apply configuration for internal to wagon org.apache.maven.wagon.providers.ssh.jsch.ScpWagon:ClassNotFoundException: Class name which was explicitly given in configuration using 'implementation' attribute: 'org.apache.maven.wagon.providers.ssh.knownhost.SingleKnownHostProvider' cannot be loaded

Why is this occurring? I am using Maven 3.0.4

Community
  • 1
  • 1
Sled
  • 18,541
  • 27
  • 119
  • 168
  • 1
    It seems that maybe your `SingleKnownHostProvider` is not a complete implementation and still needs work. Maybe it is complete, but definitely I am not able to find much documentation. Source code leaves me the clue for the `hostKeyChecking` property, but not how to manually add a host-key entry. I would love to see a followup. – YoYo Jul 31 '15 at 20:46

2 Answers2

0

AFAIU, Maven will call the external SSH command as same as when it connects to the SCM ,e.g. the SVN. To get rid of the prompt for connecting, we may need to use the SSH to connect to that host at lease once.

#--I'm using CentOS release 5.4.

[my_user]$ ssh MY_USER@MY_HOST
The authenticity of host 'MY_HOST (MY_HOST_IP)' can't be established.
RSA key fingerprint is MY_FINGER_PRINT.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'MY_HOST,MY_HOST_IP' (RSA) to the list of known hosts.

The ~/.ssh/known_hosts will contain the RSA information as the following example: -

MY_HOST,MY_HOST_IP ssh-rsa .....

Then next time, when we connect to that host there is no any prompt. The rest at settings.xml should be as mentioning at Settings Reference:Servers.

I hope this may help.

EDITED: Regarding to the Windows, please try to use the PuTTY. There are the executable file which is ready to run without any installation. The step for connecting is as the following: -

PuTTY

  1. Open the PUTTY.exe
  2. Make a connection to our host.
  3. The system will prompt to whether to save the remote RSA key or not. Please save it.
  4. After that the remote RSA key will store at windows registry HKEY_CURRENT_USER\SoftWare\SimonTatham\PuTTY\SshHostKeys
Community
  • 1
  • 1
Charlee Chitsuk
  • 8,847
  • 2
  • 56
  • 71
  • Well I am on Windows and my SCM is Perforce, so any idea how to do that? – Sled Apr 03 '13 at 13:05
  • 1
    This does not appear to be the direct answers to the questions "how to add a single fingerprint to the server.xml", and "why he could not use SingleKnownHostProvider". I am very much interested in answers to those questions. – YoYo Jul 31 '15 at 18:33
0

The first problem is that <key>81:66:27:b9:15:36:3a:91:ec:66:43:4f:69:a0:ef:c4:b9:15:36</key> is not the key but the fingerprint of the key. So it could not work, even if it was possible to specify the key this way.

To solve the problem, replace your wagon-ssh extension artifact definition in your pom.xml by the following one:

<build>
  <extensions>
    <extension>
      <groupId>org.apache.maven.wagon</groupId>
      <artifactId>wagon-ssh</artifactId>
      <version>3.0.1-SINGLE</version>
    </extension>
  </extensions>
</build>

Download and install this specific version numbered 3.0.1-SINGLE here: https://github.com/AlexandreFenyo/maven-wagon

And finally, update your settings.xml this way:

<server>
        <id>internal</id>
        <username>root</username>
        <password>p4ssw0rd</password>
        <configuration>
                <hostKey>SERVERNAME HOSTKEY</hostKey>
            </knownHostsProvider>
        </configuration>
</server>

Replace SERVERNAME by the host name just after scp: in the server URL.

Replace HOSTKEY by the content of the file that stores the SSHd public RSA key (this is often the following file: /etc/ssh/ssh_host_rsa_key.pub).

Alexandre Fenyo
  • 4,526
  • 1
  • 17
  • 24