我尝试根据说明在 Java 程序中使用 SSH 与 PythonAnywhere 中的 MySQL 库建立连接: https:
//help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere
不幸的是,我每次都会遇到这个错误,而且我已经没有想法了:
com.jcraft.jsch.JSchException:拒绝主机密钥:ssh.pythonanywhere.com
public static void main(String[] args) {
Tunnel tunnel = new Tunnel();
try {
tunnel.go();
} catch (Exception e) {
e.printStackTrace();
}
}
public void go() throws Exception {
String host = "ssh.pythonanywhere.com";
String user = "username";
String password = "password";
int port = 22;
int tunnelLocalPort = 9080;
String tunnelRemoteHost = "username.mysql.pythonanywhere-services.com";
int tunnelRemotePort = 3306;
JSch jsch= new JSch();
Session session = jsch.getSession(user,host,port);
localUserInfo lui = …Run Code Online (Sandbox Code Playgroud)