Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何让Diffie Hellman Group Exhange在Jaramiko SSH服务器上工作?_Java_Android_Ssh_Paramiko_Ssh Keys - Fatal编程技术网

Java 如何让Diffie Hellman Group Exhange在Jaramiko SSH服务器上工作?

Java 如何让Diffie Hellman Group Exhange在Jaramiko SSH服务器上工作?,java,android,ssh,paramiko,ssh-keys,Java,Android,Ssh,Paramiko,Ssh Keys,我正在尝试使用Jaramiko编写一个SSH服务器,该服务器应该运行在Android平台上 下面是行serverTransport.start(服务器接口,协商超时)上的相关代码服务器无法与客户端执行DH Group Exchange SHA 1 此日志消息已生成: 06-26 12:59:57.854 1383-1425/com.jannatec.sshs服务器D/sshs服务: 正在启动SSH会话06-26 12:59:57.940 1383-1426/com.jannatec.sshser

我正在尝试使用Jaramiko编写一个SSH服务器,该服务器应该运行在Android平台上

下面是行
serverTransport.start(服务器接口,协商超时)上的相关代码服务器无法与客户端执行DH Group Exchange SHA 1

此日志消息已生成:

06-26 12:59:57.854 1383-1425/com.jannatec.sshs服务器D/sshs服务: 正在启动SSH会话06-26 12:59:57.940 1383-1426/com.jannatec.sshserver W/System.err:424[jaramiko服务器 馈线]INFO net.lag.jaramiko.BaseTransport-已连接(版本2.0, 客户油灰释放(0.69)06-26 12:59:58.670 1383-1426/com.jannatec.sshserver W/System.err:1155[jaramiko服务器 feeder]WARN net.lag.jaramiko.BaseTransport-Oops,未处理的数据包 类型kex4 06-26 12:59:58.678 1383-1426/com.jannatec.sshserver W/System.err:1163[jaramiko服务器馈线]信息 net.lag.jaramiko.BaseTransport-断开连接(代码2):服务器协议 违反:意外的SSH2\u MSG\u未实现数据包06-26 12:59:58.730 1383-1425/com.jannatec.sshs服务器E/sshs服务:协商失败

我使用PuTTY作为SSH客户端,如何使密钥交换工作

@Override
    public void run() {
        try {
            Log.d(TAG, "Creating transport");
            serverTransport = new ServerTransport(socket);
        } catch (IOException ie) {
            Log.e(TAG, "Cannot create transport");
        }

        final String privateKeyPath = getFilesDir() + "/private.key";
        final String password = "Eh3rLFOtbQoB8jaAQE5i"; 
        File privateKeyFile = new File(privateKeyPath);
        RSAKey rsaKey = null;
        CraiJCE craiJCE = new CraiJCE();
        if (privateKeyFile.exists()) {
            Log.d(TAG, "Host key found, loading stored host key");
            try {
                FileInputStream is = new FileInputStream(privateKeyPath);
                rsaKey = (RSAKey) PKey.readPrivateKeyFromStream(is, password);
                is.close();
            } catch (IOException ie) {
                Log.e(TAG, "Cannot load stored key");
            }
        }

        // if there is error loading the key or key does not exist, create a new one
        if (rsaKey == null) {
            Log.d(TAG, "No stored host key found, generating new key");
            try {
                rsaKey = RSAKey.generate(craiJCE, 1024);

                Log.d(TAG, "Key generated, storing key");
                FileOutputStream os = new FileOutputStream(privateKeyPath);
                rsaKey.writePrivateKeyToStream(os, password);
                os.close();
            } catch (SSHException sshe) {
                Log.e(TAG, "Key generation error");
            } catch (IOException ie) {
                Log.e(TAG, "Cannot store key file");
            }
        }

        serverTransport.addServerKey(rsaKey); 
        if (BANNER.length() > 0) {
            serverTransport.setServerBanner(BANNER + "\n");
        }
        serverTransport.setKeepAlive(60000);
        try {
            Log.d(TAG, "Starting SSH session");
            serverTransport.start(serverInterface, NEGOTIATION_TIME_OUT);

        } catch (SSHException sshe) {
            Log.e(TAG, "Negotiation failed");
            cancel();
        } catch (IOException ie) {
            Log.e(TAG, "Socket IO exception");
            cancel();
        }
    }