0

I'm using wagon-maven-plugin in my pom.xml to upload JAR file to one of my remote servers.

Here is the introduction and usage of this plugin: https://www.mojohaus.org/wagon-maven-plugin/

I followed the configuration from this post, as well as its official documentation:

Now everything works fine for me - I can successfully upload the JAR and execute some shell commands, except that every time I execute the maven goals, it keeps poping up with a RSA key fingerprint of the remote server and asks me whether I want to continue.

The output info shows like this:

[INFO] --- wagon-maven-plugin:2.0.2:upload-single (upload-jar-to-app01) @ my-app ---
The authenticity of host 'localhost' can't be established.
RSA key fingerprint is ef:04:e4:2d:fa:0f:ee:78:ff:94:b1:dc:07:32:00:f3.
Are you sure you want to continue connecting? (yes/no): yes

Is there any way to avoid this? So that I don't have to type "yes" every time.

  • What you mean by `file to one of my remote servers.`... is this a repository manager or is that a deployment to one of your server ? – khmarbaise Jul 22 '21 at 08:57
  • "my remote servers" is a typical Linux server, instead of a "repository" – Benjamin Leon Jul 22 '21 at 09:40
  • Is there a good reason why you like to handle that via Maven instead with other tools? Apart from that I recommend to use wagon https://maven.apache.org/wagon/index.html instead of MojoHaus variant... furthermore I would recommend to build with Maven and do the transfer to the target server with other tools... (corporate envirionment?) – khmarbaise Jul 22 '21 at 11:20
  • Thanks for the recommendation! I will check it out :) I'm using wagon-maven-plugin because it is the first thing I found on Google, and it seems to get my task done very well too - whenever I run "mvn clean package", it can automatically upload my app JAR to a directory on server and execute a few simple shell commands. – Benjamin Leon Jul 22 '21 at 14:02
  • Yes, it is a corporate environment – Benjamin Leon Jul 22 '21 at 14:03
  • Why not using a tool like jenkins to deploy to the appropriate environment... would thinks much more easier. You simply can do in your ci `mvn clean deploy` and another job can do the deployment on target server...It is also a good separation of concern. – khmarbaise Jul 22 '21 at 14:31
  • @khmarbaise Yes I know about Jenkins, and we are using it to build apps too. Here is what we have been doing with Jenkins: 1) we commit and push the code to Git repo; 2) Jenkins pulls the code from Git repo and build it; 3) Jenkins deploys it to server and maybe run some shell commands. But it seems too "heavy" for me(it takes some time to finish all the steps) if I frequently change my code and test it on server. So I'm thinking if there are any light way to do this, especially I want to skip the "git commit / git push" part. – Benjamin Leon Jul 22 '21 at 15:40
  • Skipping commit and push? So testing something which is not reproducible... wow that's from my point of view an bad path... The question why are you trying to prevent those steps.. Apart from that it's a usual approach work on a branch push that and let the server do the work.. also deploying on test environments or writing automatic tests which handle things... the question is: What kind of tests are you doing on that one you would like to deploy to without commit? – khmarbaise Jul 22 '21 at 15:46
  • @khmarbaise I saw you mention `mvn clean deploy`, thinking you are talking about letting maven to `deploy` my JAR to a repository, and Jenkins will do the rest. I don't have much knowledge about "repository", maybe I need to setup an environment hosting the JAR files? Like Nexus? – Benjamin Leon Jul 22 '21 at 15:52
  • I thought you wrote corporate environment. Based on that my assumption was that this is already in place which I strongly recommend.... Nexus yes... – khmarbaise Jul 22 '21 at 15:57
  • 1
    @khmarbaise Aha, yes it is corporate environment and we don't have Nexus yet! Sounds like I need to do some research about it and maybe recommend this to my team... Talking about skipping commit, I didn't mean to totally skip that. Suppose I'm working on a feature branch, before I commit my code I will run the whole set of unit tests locally, and may want to manually test it on server (test environment). Then if everything works well I will commit my code to Git repo, thinking this would avoid some unnecessary small commits? – Benjamin Leon Jul 22 '21 at 16:27

1 Answers1

1

I think I found the solution to this issue.

Actually this have nothing to do with wagon-maven-plugin, the RSA key fingerprint pop-up is coming from a SSH client, which is implemented by Maven Wagon - yes, I also had this component as an extension in my pom.xml:

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

To solve this, I just need to upgrade this extension to the latest version 3.4.3, which it has feature to allow us to add parameters when connencting server via SSH. Pleases refer to this closed Github issue

The parameters should be added to server configuration in settings.xml, which looks like this:

<settings>
    ...
    <servers>
        <server>
          <id>my-servers</id>
          <username>name</username>
          <password>password</password>
          <configuration>
            <strictHostKeyChecking>no</strictHostKeyChecking>
            <preferredAuthentications>publickey,password</preferredAuthentications>
            <interactive>false</interactive>
          </configuration>
        </server>
    </servers>
    ...
</settings>