问题
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?
回答1:
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.) The Deploy Plugin documentation still has a guide called Deployment of artifacts in an external SSH command, but this approach is not necessary anymore.
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>
来源:https://stackoverflow.com/questions/5819775/is-there-any-way-of-having-maven-scp-wagon-work-consistently-on-linux-mac-window