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

[Discussing] Can I add SSH connections to JDBC data sources? #3520

Open
3 tasks done
mdzz9527 opened this issue May 23, 2024 · 6 comments
Open
3 tasks done

[Discussing] Can I add SSH connections to JDBC data sources? #3520

mdzz9527 opened this issue May 23, 2024 · 6 comments
Labels
Invalid Invalid New Feature New feature

Comments

@mdzz9527
Copy link

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Description

jdbc数据源是否可以增加ssh的连接方式

Use case

No response

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@mdzz9527 mdzz9527 added New Feature New feature Waiting for reply Waiting for reply labels May 23, 2024
@Zzm0809
Copy link
Contributor

Zzm0809 commented May 23, 2024

请详细描述一下

@mdzz9527
Copy link
Author

出于安全考虑,或者是其他,有些数据源不能直接连接,是通过SSH的跳板机的方式连接的,大部分数据库连接工具是支持这种连接方式的,比如navicat
image

@Zzm0809
Copy link
Contributor

Zzm0809 commented May 23, 2024

非必须功能,目前社区暂无此计划,如你对此功能有兴趣可以实现,欢迎贡献社区

@Zzm0809 Zzm0809 removed the Waiting for reply Waiting for reply label May 31, 2024
@Zzm0809 Zzm0809 changed the title Can I add SSH connections to JDBC data sources? [Discussing] Can I add SSH connections to JDBC data sources? May 31, 2024
@Zzm0809
Copy link
Contributor

Zzm0809 commented May 31, 2024

你可以使用 jsch 库完成以上需求

  <!-- https://mvnrepository.com/artifact/com.github.mwiede/jsch -->
            <dependency>
                <groupId>com.github.mwiede</groupId>
                <artifactId>jsch</artifactId>
                <version>${jssh.version}</version>
            </dependency>
  1. 创建 jdbc 的 ssh 链接配置类
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class JdbcSSHConnectConfig {



    @ApiModelProperty(
            value = "SSH host",
            dataType = "String",
            example = "192.168.127.12",
            notes = "SSH host")
    private String sshHost;

    @ApiModelProperty(
            value = "SSH port",
            dataType = "Integer",
            example = "22",
            notes = "SSH port")
    private int sshPort;

    @ApiModelProperty(
            value = "SSH username",
            dataType = "String",
            example = "root",
            notes = "SSH username")
    private String sshUsername;

    @ApiModelProperty(
            value = "SSH password",
            dataType = "String",
            example = "root",
            notes = "SSH password")
    private String sshPassword;

    @ApiModelProperty(
            value = "Local forward port",
            dataType = "Integer",
            example = "3306",
            notes = "Local forward port")
    private int localForwardPort;
}
  1. org.dinky.metadata.config.AbstractJdbcConfig 中添加如下属性
    @ApiModelProperty(
            value = "Whether to use ssh tunnel", example = "true", notes = "Whether to use ssh tunnel")
    private boolean useSshTunnel = false;
    @ApiModelProperty(
            value = "Whether to use ssh tunnel", example = "true", notes = "Whether to use ssh tunnel")
    private JdbcSSHConnectConfig sshConnectConfig;

其他代码自行根据逻辑实现

@github-actions github-actions bot added the Invalid Invalid label Jul 1, 2024
Copy link

github-actions bot commented Jul 1, 2024

Hello @, this issue has not been active for more than 30 days. This issue will be closed in 7 days if there is no response. If you have any questions, you can comment and reply.

你好 @, 这个 issue 30 天内没有活跃,7 天后将关闭,如需回复,可以评论回复。

@mdzz9527
Copy link
Author

mdzz9527 commented Jul 8, 2024

好的,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Invalid Invalid New Feature New feature
Projects
None yet
Development

No branches or pull requests

2 participants