GeXiangDong

精通Java、SQL、Spring的拼写,擅长Linux、Windows的开关机

0%

deploy maven artifacts to remote SSH servers by wagon-ssh-external component

Maven’s wagon-ssh-external component enables deploying artifacts to remote SSH servers by leveraging an external SSH client. It requires an already installed SSH program on the system and allows Maven to interact with the remote server for deployments.

Key Concepts and Usage:

Wagon Provider:

wagon-ssh-external is a Wagon provider, meaning it implements the Wagon API for interacting with remote repositories.

External SSH Client:

This component relies on an existing SSH client (like OpenSSH) being installed on the machine where Maven is running.

Deployment:

It’s primarily used for deploying artifacts (JARs, WARs, etc.) and website content to SSH servers.

Configuration:

pom.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>3.5.3</version>
</extension>
</extensions>
</build>

<distributionManagement>
<repository>
<id>ssh-repository </id>
<url>scpexe://your_username@ssh-host-name-or-ip/path/to/your/repository</url>
</repository>
</distributionManagement>

...

  1. in url, scpexe:// instead of scp://
  2. if already configred ssh login to ssh server by rsa keys, then the above configuration will work without below setting.xml changed.
  3. if need password or scp command … configure in setting.xml as below.

setting.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...

<settings>
<servers>
<server>
<id>ssh-repository</id>
<username>your_username</username>
<privateKey>/path/to/your/private/key</privateKey>
<password>or-password-here</password>
<!-- Not needed if using pageant -->
<configuration>
<sshExecutable>plink</sshExecutable> <!-- Or your SSH client -->
<scpExecutable>pscp</scpExecutable> <!-- Or your SCP client -->
<sshArgs>-o StrictHostKeyChecking=no</sshArgs> <!-- Example: no host key checking -->
</configuration>
</server>
</servers>
</settings>

...