我正在尝试使用SSH将我的Android设备连接到Raspi。当我尝试连接时,我的应用程序关闭

时间:2014-01-21 07:50:34

标签: session

public void Connect() {
    JSch jsch = new JSch();
    try {

        jsch.setConfig("StrictHostKeyChecking", "no");

        //open a new session
        session = jsch.getSession(user, host, port); // pi, 192.168.43.213, 22
        session.setConfig("StrictHostKeyChecking", "no");
        session.setPassword(password); //passwrord : raspberry

        tv.setText("Connecting");
        session.connect(1000);//connect session
        tv.setText("Connected");

    } catch (JSchException e) {
        tv.setText("JSchException");
        Toast t = Toast.makeText(ClientSSH.this, "Failed to Create Session or Timed Out", 1000);
        t.setGravity(Gravity.CENTER, 0, 0);
        t.show();

    } 
}

0 个答案:

没有答案