mavensettingsrsamaven-wagon-plugin

How to use the SingleKnownHostProvider in the `settings.xml`?


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


Solution

  • 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