Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way of having maven scp wagon work consistently on linux/mac/windows platform?

Given the very poor documentation about scp/ssh and maven I tried different approaches, basically falling in two main categories: using scpexe wagon and scp wagon. Usually they both work without issue on both linux and mac, but on windows I never found a way to make it work on all machines.

scpexe approach (after installing complete putty and adding to path) - settings.xml configuration:

<server>
    <id>internal</id>
    <username>******</username>
    <password>*******</password>
    <configuration>
        <sshExecutable>plink</sshExecutable>
        <scpExecutable>pscp</scpExecutable>
    </configuration>
</server>

scp approach - settings.xml :

 <server>
      <id>internal</id>
      <username>*********</username>
      <password>*********</password>
      <configuration>
           <StrictHostKeyChecking>ask</StrictHostKeyChecking>
      </configuration>
 </server>

I also tried putting StrictHostKeyChecking to "no", but, security risks aside, did not work on a particular machine.

Has someone found a way to use an internal ssh repository consistently on all machines?

like image 280
Riccardo Cossu Avatar asked Apr 28 '11 13:04

Riccardo Cossu


1 Answers

There are three potential approaches to deploy Maven artifacts via SSH/SCP:

  • wagon-ssh (deprecated)
  • wagon-ssh-external (platform-specific concerns)
  • A wagon-ssh rewrite built on Apache Mina SSHD (does not actually exist yet as of this writing)

1. wagon-ssh

The Maven SSH wagon uses JSch, the pure-Java implementation of SSH, which works regardless of OS. (Perhaps that was not the case when this question was originally posted, but it is true now.)

Here is a sample configuration which I successfully used to deploy over SCP to a Linux box from a Windows 7 system with Maven 3.0.4.

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>hello</groupId>
  <artifactId>hello</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>

  <name>Hello</name>

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

  <distributionManagement>
    <repository>
      <id>my-ssh-repo</id>
      <url>scp://my.server.url/path/to/ssh-repo</url>
    </repository>
  </distributionManagement>

</project>

settings.xml:

<settings>
  <servers>
    <server>
      <id>my-ssh-repo</id>
      <username>myUser</username>
      <password>myPass</password>
    </server>
  </servers>
</settings>

Unfortunately, this wagon is now deprecated for two reasons: it is built on JSch which is not fully open source, and it is difficult to maintain due to complex and low level code needed. See WAGON-616 for details.

2. wagon-ssh-external

The Maven SSH External Wagon calls out to your system SSH/SCP commands. Unfortunately, there are some OS-specific configuration issues, particularly on Windows, as explained in the Deployment of artifacts in an external SSH command guide, and as highlighted in the question above.

3. wagon-ssh rewrite using Apache Mina SSHD

A viable hope for a pure-Java SSH/SCP wagon would be to rework the wagon-ssh implementation to use Apache Mina SSHD instead of JSch. Unfortunately, no one has actually done this yet, but the maintainer of wagon-ssh has indicated that it could be un-deprecated should anyone in the community step forward to tackle the project.

like image 128
ctrueden Avatar answered Oct 04 '22 23:10

ctrueden