有没有办法让maven scp wagon在linux/mac/windows平台上一致工作?

发布于 2024-11-04 05:10:18 字数 1004 浏览 2 评论 0原文

鉴于关于 scp/ssh 和 maven 的文档非常差,我尝试了不同的方法,基本上分为两个主要类别:使用 scpexe wagon 和 scp wagon。通常它们在 Linux 和 Mac 上都可以正常工作,但在 Windows 上我从未找到一种方法让它在所有机器上工作。

scpexe 方法(安装完整的腻子并添加到路径后)-settings.xml 配置:

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

scp 方法-settings.xml :

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

我还尝试将 StrictHostKeyChecking 设置为“否”,但是,除了安全风险之外,在特定计算机上不起作用。

有人找到了在所有机器上一致使用内部 ssh 存储库的方法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青丝拂面 2024-11-11 05:10:18

通过 SSH/SCP 部署 Maven 工件有三种可能的方法:

  • wagon-ssh (已弃用)
  • wagon-ssh-external (特定于平台的问题)
  • wagon -ssh 重写构建在 Apache Mina SSHD 上(实际上并不存在截至本文撰写时)

1. wagon-ssh

Maven SSH wagon 使用 JSch,SSH 的纯 Java 实现,无论操作系统如何,它都可以工作。 (也许最初发布这个问题时情况并非如此,但现在确实如此。)

这是一个示例配置,我成功地使用它通过 SCP 从 Windows 7 系统和 Maven 3.0.4 部署到 Linux 机器。

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>

不幸的是,这个 wagon 现在已被弃用,原因有两个:它是基于 JSch 构建的,JSch 不是完全开源的,而且很难由于需要复杂且低级的代码而需要维护。有关详细信息,请参阅 WAGON-616

2. wagon-ssh-external

Maven SSH 外部 Wagon 调用您的系统 SSH/SCP 命令。不幸的是,存在一些特定于操作系统的配置问题,特别是在 Windows 上,如 在外部 SSH 命令中部署工件 指南,如上面问题中突出显示的那样。

3. 使用 Apache Mina SSHD 重写 wagon-ssh

纯 Java SSH/SCP wagon 的一个可行希望是重写 wagon-ssh 实现以使用 Apache Mina SSHD 而不是 JSch。不幸的是,目前还没有人真正做到这一点,但 wagon-ssh 的维护者表示,如果社区中的任何人挺身而出解决该项目,它可能会被取消弃用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文