Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fixed an issue where selecting password for MySQL SSH connection resulted in an error: 'PrivateKey Path must be not empty!' #247

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ai.chat2db.spi.enums;

import ai.chat2db.server.tools.base.enums.BaseEnum;

public enum SSHAuthenticationTypeEnum implements BaseEnum<String> {
/**
* 密钥文件
*/
KEYFILE("密钥文件"),
/**
* 密码
*/
PASSWORD("密码"),
/**
* 未知
*/
UNKNOWN("未知"),

;

final String description;

SSHAuthenticationTypeEnum(String description) {
this.description = description;
}

@Override
public String getCode() {
return this.name();
}

@Override
public String getDescription() {
return description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.security.Security;

import ai.chat2db.server.tools.common.exception.ConnectionException;
import ai.chat2db.spi.enums.SSHAuthenticationTypeEnum;
import ai.chat2db.spi.model.SSHInfo;
import cn.hutool.core.net.NetUtil;
import cn.hutool.extra.ssh.JschUtil;
Expand Down Expand Up @@ -33,7 +34,7 @@ public class SSHManager {
public static Session getSSHSession(SSHInfo ssh) {
Session session = null;
try {
if (StringUtils.isNotBlank(ssh.getKeyFile())) {
if (SSHAuthenticationTypeEnum.KEYFILE.name().equals(ssh.getAuthenticationType())) {
byte[] passphrase = StringUtils.isNotBlank(ssh.getPassphrase()) ? StringUtils.getBytes(
ssh.getPassphrase(),
"UTF-8") : null;
Expand Down