pre ssh modules

This commit is contained in:
bwcx_jzy 2023-04-06 14:00:39 +08:00
parent 5dc9911548
commit afb30ce4c3
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
20 changed files with 416 additions and 55 deletions

View File

@ -22,7 +22,6 @@
*/
package org.dromara.jpom.common.commander;
import cn.hutool.cache.impl.LRUCache;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DatePattern;
@ -61,6 +60,7 @@ import org.springframework.util.Assert;
import java.io.File;
import java.nio.charset.Charset;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import java.util.jar.Attributes;
@ -84,7 +84,7 @@ public abstract class AbstractProjectCommander {
/**
* 进程Id 获取端口号
*/
public static final LRUCache<Integer, String> PID_PORT = new LRUCache<>(100, TimeUnit.MINUTES.toMillis(10));
public static final Map<Integer, CacheObject<String>> PID_PORT = new ConcurrentHashMap<>();
private final Charset fileCharset;
@ -629,7 +629,7 @@ public abstract class AbstractProjectCommander {
if (pid <= 0) {
return StrUtil.DASHED;
}
String cachePort = PID_PORT.get(pid);
String cachePort = CacheObject.get(PID_PORT, pid);
if (cachePort != null) {
return cachePort;
}
@ -656,7 +656,7 @@ public abstract class AbstractProjectCommander {
}
String allPort = CollUtil.join(ports, StrUtil.COMMA);
// 缓存
PID_PORT.put(pid, allPort);
CacheObject.put(PID_PORT, pid, allPort);
return allPort;
}

View File

@ -0,0 +1,91 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Code Technology Studio
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package org.dromara.jpom.common.commander;
import cn.hutool.core.date.SystemClock;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @author bwcx_jzy
* @since 2023/4/6
*/
public class CacheObject<T> {
private final T value;
private final Long enterTime;
public CacheObject(T value) {
this.value = value;
this.enterTime = SystemClock.now();
}
private boolean isExpired() {
return (System.currentTimeMillis() - this.enterTime > TimeUnit.MINUTES.toMillis(10));
}
/**
* 添加到缓存对象中
*
* @param map map
* @param key 缓存的 key
* @param value 缓存的 value
* @param <K> 缓存的 key
* @param <V> 缓存的 value
*/
public static <K, V> void put(Map<K, CacheObject<V>> map, K key, V value) {
map.put(key, new CacheObject<>(value));
int size = map.size();
if (size > 100) {
// 清空过期的数据
Iterator<Map.Entry<K, CacheObject<V>>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<K, CacheObject<V>> next = iterator.next();
CacheObject<V> nextValue = next.getValue();
if (nextValue.isExpired()) {
iterator.remove();
}
}
}
}
/**
* 获取缓存中的值
*
* @param map 缓存 map
* @param key 缓存的 key
* @param <K> 缓存的 key
* @return value
*/
public static <K, V> V get(Map<K, CacheObject<V>> map, K key) {
CacheObject<V> cacheObject = map.get(key);
if (cacheObject.isExpired()) {
map.remove(key);
return null;
}
return cacheObject.value;
}
}

View File

@ -78,10 +78,7 @@
<groupId>cn.hutool</groupId>
<artifactId>hutool-cron</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-cache</artifactId>
</dependency>
<!-- aop-->
<dependency>

View File

@ -22,7 +22,6 @@
*/
package org.dromara.jpom;
import cn.hutool.cache.GlobalPruneTimer;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.thread.GlobalThreadPool;
@ -250,7 +249,6 @@ public class JpomApplication implements DisposableBean, InitializingBean {
executorService.shutdownNow();
}
});
GlobalPruneTimer.INSTANCE.shutdownNow();
}
@Override

View File

@ -60,9 +60,9 @@
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.55</version>
<groupId>org.dromara.jpom.plugins</groupId>
<artifactId>ssh-jsch</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@ -129,11 +129,17 @@
<artifactId>storage-module-mysql</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.16.5</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-cache</artifactId>
</dependency>
</dependencies>
<build>
<resources>

View File

@ -65,6 +65,7 @@ import org.dromara.jpom.model.user.UserModel;
import org.dromara.jpom.outgiving.OutGivingRun;
import org.dromara.jpom.plugin.IPlugin;
import org.dromara.jpom.plugin.PluginFactory;
import org.dromara.jpom.plugins.JschUtils;
import org.dromara.jpom.service.docker.DockerInfoService;
import org.dromara.jpom.service.docker.DockerSwarmInfoService;
import org.dromara.jpom.service.node.NodeService;

View File

@ -55,7 +55,7 @@ import org.dromara.jpom.service.node.ssh.SshService;
import org.dromara.jpom.system.ServerConfig;
import org.dromara.jpom.util.CommandUtil;
import org.dromara.jpom.util.CompressionFileUtil;
import org.dromara.jpom.util.JschUtils;
import org.dromara.jpom.plugins.JschUtils;
import org.dromara.jpom.util.StringUtil;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;

View File

@ -24,6 +24,7 @@ package org.dromara.jpom.func.assets.model;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import lombok.Data;
@ -32,6 +33,7 @@ import lombok.NoArgsConstructor;
import org.dromara.jpom.db.TableName;
import org.dromara.jpom.model.BaseGroupNameModel;
import org.dromara.jpom.model.data.SshModel;
import org.dromara.jpom.plugins.ISshInfo;
import java.nio.charset.Charset;
import java.util.List;
@ -46,7 +48,7 @@ import java.util.concurrent.TimeUnit;
@TableName(value = "MACHINE_SSH_INFO", name = "机器SSH信息")
@Data
@NoArgsConstructor
public class MachineSshModel extends BaseGroupNameModel {
public class MachineSshModel extends BaseGroupNameModel implements ISshInfo {
/**
* 主机地址
@ -175,15 +177,47 @@ public class MachineSshModel extends BaseGroupNameModel {
}
}
public MachineSshModel.ConnectType connectType() {
@Override
public String id() {
return getId();
}
@Override
public String host() {
return getHost();
}
@Override
public String user() {
return getUser();
}
@Override
public String password() {
return getPassword();
}
@Override
public String privateKey() {
return getPrivateKey();
}
@Override
public int port() {
return ObjectUtil.defaultIfNull(getPort(), 0);
}
@Override
public ISshInfo.ConnectType connectType() {
return EnumUtil.fromString(MachineSshModel.ConnectType.class, this.connectType, MachineSshModel.ConnectType.PASS);
}
/**
* 超时时间
*
* @return 最小值 1 分钟
* @return 最小值 1
*/
@Override
public int timeout() {
if (this.timeout == null) {
return (int) TimeUnit.SECONDS.toMillis(5);
@ -191,20 +225,8 @@ public class MachineSshModel extends BaseGroupNameModel {
return (int) TimeUnit.SECONDS.toMillis(Math.max(1, this.timeout));
}
@Override
public Charset charset() {
return CharsetUtil.parse(this.getCharset(), CharsetUtil.CHARSET_UTF_8);
}
public enum ConnectType {
/**
* 账号密码
*/
PASS,
/**
* 密钥
*/
PUBKEY
}
}

View File

@ -53,10 +53,11 @@ import org.dromara.jpom.func.assets.model.MachineSshModel;
import org.dromara.jpom.model.data.SshModel;
import org.dromara.jpom.plugin.IWorkspaceEnvPlugin;
import org.dromara.jpom.plugin.PluginFactory;
import org.dromara.jpom.plugins.ISshInfo;
import org.dromara.jpom.service.h2db.BaseDbService;
import org.dromara.jpom.service.node.ssh.SshService;
import org.dromara.jpom.system.ExtConfigBean;
import org.dromara.jpom.util.JschUtils;
import org.dromara.jpom.plugins.JschUtils;
import org.dromara.jpom.util.StringUtil;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
@ -342,13 +343,13 @@ public class MachineSshServer extends BaseDbService<MachineSshModel> implements
* @param sshModel sshModel
* @return session
*/
public Session getSessionByModelNoFill(MachineSshModel sshModel) {
public Session getSessionByModelNoFill(ISshInfo sshModel) {
Assert.notNull(sshModel, "没有对应 SSH 信息");
Session session = null;
int timeout = sshModel.timeout();
MachineSshModel.ConnectType connectType = sshModel.connectType();
String user = sshModel.getUser();
String password = sshModel.getPassword();
String user = sshModel.user();
String password = sshModel.password();
// 转化密码字段
IWorkspaceEnvPlugin plugin = (IWorkspaceEnvPlugin) PluginFactory.getPlugin(IWorkspaceEnvPlugin.PLUGIN_NAME);
try {
@ -358,11 +359,11 @@ public class MachineSshServer extends BaseDbService<MachineSshModel> implements
throw Lombok.sneakyThrow(e);
}
if (connectType == MachineSshModel.ConnectType.PASS) {
session = JschUtil.openSession(sshModel.getHost(), sshModel.getPort(), user, password, timeout);
session = JschUtil.openSession(sshModel.host(), sshModel.port(), user, password, timeout);
} else if (connectType == MachineSshModel.ConnectType.PUBKEY) {
File rsaFile = null;
String privateKey = sshModel.getPrivateKey();
String privateKey = sshModel.privateKey();
byte[] passwordByte = StrUtil.isEmpty(password) ? null : StrUtil.bytes(password);
//sshModel.password();
if (StrUtil.startWith(privateKey, URLUtil.FILE_URL_PREFIX)) {
@ -370,8 +371,8 @@ public class MachineSshServer extends BaseDbService<MachineSshModel> implements
rsaFile = FileUtil.file(rsaPath);
} else if (StrUtil.startWith(privateKey, JschUtils.HEADER)) {
// 直接采用 private key content 登录无需写入文件
session = JschUtils.createSession(sshModel.getHost(),
sshModel.getPort(),
session = JschUtils.createSession(sshModel.host(),
sshModel.port(),
user,
StrUtil.trim(privateKey),
passwordByte);
@ -388,7 +389,7 @@ public class MachineSshServer extends BaseDbService<MachineSshModel> implements
} else {
//这里的实现用于把 private key 写入到一个临时文件中此方式不太采取
File tempPath = JpomApplication.getInstance().getTempPath();
String sshFile = StrUtil.emptyToDefault(sshModel.getId(), IdUtil.fastSimpleUUID());
String sshFile = StrUtil.emptyToDefault(sshModel.id(), IdUtil.fastSimpleUUID());
rsaFile = FileUtil.file(tempPath, "ssh", sshFile);
FileUtil.writeString(privateKey, rsaFile, CharsetUtil.UTF_8);
}
@ -396,8 +397,8 @@ public class MachineSshServer extends BaseDbService<MachineSshModel> implements
if (session == null) {
// 简要私钥文件是否存在
Assert.state(FileUtil.isFile(rsaFile), "私钥文件不存在:" + FileUtil.getAbsolutePath(rsaFile));
session = JschUtil.createSession(sshModel.getHost(),
sshModel.getPort(), user, FileUtil.getAbsolutePath(rsaFile), passwordByte);
session = JschUtil.createSession(sshModel.host(),
sshModel.port(), user, FileUtil.getAbsolutePath(rsaFile), passwordByte);
}
try {
session.setServerAliveInterval(timeout);

View File

@ -47,6 +47,7 @@ import org.dromara.jpom.model.EnvironmentMapBuilder;
import org.dromara.jpom.model.PageResultDto;
import org.dromara.jpom.model.data.NodeModel;
import org.dromara.jpom.model.data.SshModel;
import org.dromara.jpom.plugins.JschUtils;
import org.dromara.jpom.service.IStatusRecover;
import org.dromara.jpom.service.h2db.BaseWorkspaceService;
import org.dromara.jpom.service.node.NodeService;

View File

@ -41,6 +41,7 @@ import org.dromara.jpom.model.data.CommandExecLogModel;
import org.dromara.jpom.model.data.CommandModel;
import org.dromara.jpom.model.data.SshModel;
import org.dromara.jpom.model.user.UserModel;
import org.dromara.jpom.plugins.JschUtils;
import org.dromara.jpom.script.CommandParam;
import org.dromara.jpom.service.ITriggerToken;
import org.dromara.jpom.service.h2db.BaseWorkspaceService;

View File

@ -22,6 +22,7 @@
*/
package org.dromara.jpom.system.db;
import cn.hutool.cache.GlobalPruneTimer;
import cn.hutool.core.collection.CollStreamUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.exceptions.CheckedUtil;
@ -148,15 +149,15 @@ public class InitDb implements DisposableBean, ILoadEvent {
// 执行回调方法
log.debug("需要执行 {} 个回调", AFTER_CALLBACK.size());
long count = AFTER_CALLBACK.entrySet()
.stream()
.mapToInt(value -> {
log.info("开始执行数据库事件:{}", value.getKey());
Supplier<Boolean> supplier = value.getValue();
boolean arg2 = supplier.get();
int code = arg2 ? 1 : 0;
log.info("数据库 {} 事件执行结束,{}", value.getKey(), code);
return code;
}).sum();
.stream()
.mapToInt(value -> {
log.info("开始执行数据库事件:{}", value.getKey());
Supplier<Boolean> supplier = value.getValue();
boolean arg2 = supplier.get();
int code = arg2 ? 1 : 0;
log.info("数据库 {} 事件执行结束,{}", value.getKey(), code);
return code;
}).sum();
if (count > 0) {
// 因为导入数据后数据结构可能发生变动
// 第二次初始化数据库
@ -217,7 +218,7 @@ public class InitDb implements DisposableBean, ILoadEvent {
Db.use(dataSource).tx((CheckedUtil.VoidFunc1Rt<Db>) parameter -> {
// 分隔后执行mysql 不能执行多条 sql 语句
List<String> list = StrUtil.isEmpty(sqlBuilderService.delimiter()) ?
CollUtil.newArrayList(sql) : StrUtil.splitTrim(sql, sqlBuilderService.delimiter());
CollUtil.newArrayList(sql) : StrUtil.splitTrim(sql, sqlBuilderService.delimiter());
int rows = list.stream().mapToInt(value -> {
try {
return parameter.execute(value);
@ -237,6 +238,8 @@ public class InitDb implements DisposableBean, ILoadEvent {
public void destroy() throws Exception {
// 需要优先关闭线程池避免异常更新数据的逻辑没有释放
JpomApplication.shutdownGlobalThreadPool();
//
GlobalPruneTimer.INSTANCE.shutdownNow();
// 关闭数据库
IoUtil.close(StorageServiceFactory.get());
}

View File

@ -20,7 +20,6 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.SystemClock;

View File

@ -20,7 +20,6 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.lang.Dict;

View File

@ -20,7 +20,6 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import com.github.dockerjava.core.NameParser;
import org.junit.Test;

View File

@ -40,6 +40,7 @@
<module>docker-cli</module>
<module>git-clone</module>
<module>encrypt</module>
<module>ssh-jsch</module>
</modules>
<modelVersion>4.0.0</modelVersion>
<version>2.10.40.2</version>

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License (MIT)
Copyright (c) 2019 Code Technology Studio
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>jpom-plugins-parent</artifactId>
<groupId>org.dromara.jpom.plugins</groupId>
<version>2.10.40.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>plugin-ssh-jsch</name>
<artifactId>ssh-jsch</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.dromara.jpom</groupId>
<artifactId>common</artifactId>
<scope>provided</scope>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.55</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<!-- 是否指定项目classpath下的依赖 -->
<addClasspath>true</addClasspath>
<!-- 指定依赖的时候声明前缀 -->
<classpathPrefix>./</classpathPrefix>
</manifest>
<manifestEntries>
<!-- 项目版本号 -->
<Jpom-Project-Version>${project.version}</Jpom-Project-Version>
<!-- 打包时间 -->
<Jpom-Timestamp>${maven.build.timestamp}</Jpom-Timestamp>
<Jpom-Type>${project.artifactId}</Jpom-Type>
<Implementation-URL>https://gitee.com/dromara/Jpom</Implementation-URL>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<!--这里要替换成jar包main方法所在类 -->
</manifest>
</archive>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>script/release.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- 指定在打包节点执行jar包合并操作 -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License (MIT)
Copyright (c) 2019 Code Technology Studio
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>release</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>jar</format>
</formats>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
<includes>
<include>com.jcraft:jsch</include>
</includes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.directory}/classes</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>

View File

@ -0,0 +1,71 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Code Technology Studio
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package org.dromara.jpom.plugins;
import java.nio.charset.Charset;
/**
* @author bwcx_jzy
* @since 2023/4/6
*/
public interface ISshInfo {
int timeout();
String host();
ConnectType connectType();
Charset charset();
int port();
String user();
String password();
/**
* 私钥
*
* @return 私钥
*/
String privateKey();
/**
* id
*
* @return 数据id
*/
String id();
enum ConnectType {
/**
* 账号密码
*/
PASS,
/**
* 密钥
*/
PUBKEY
}
}

View File

@ -20,7 +20,7 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package org.dromara.jpom.util;
package org.dromara.jpom.plugins;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
@ -36,6 +36,7 @@ import com.jcraft.jsch.*;
import lombok.Lombok;
import lombok.extern.slf4j.Slf4j;
import org.dromara.jpom.system.ExtConfigBean;
import org.dromara.jpom.util.StringUtil;
import java.io.ByteArrayOutputStream;
import java.io.File;