I am trying to connection through SSH to my server using JSCH.

JSch jsch = new JSch();
    jsch.setConfig("StrictHostKeyChecking", "no");
    session = jsch.getSession(this.username, this.host, 22);
    session.setPassword(this.password);
    Properties config = new java.util.Properties();
    config.put("StrictHostKeyChecking", "no");
    session.setConfig(config);
    this.session.connect();

The error arrives on the session.connect on the last line

12-10 00:21:35.696: W/System.err(30732): com.jcraft.jsch.JSchException: java.net.UnknownHostException: Unable to resolve host "android.widget.EditText{4257c438 VFED..CL .F....ID 219,0-849,117 #7f080008 app:id/host}": No address associated with hostname

I can successfuly reach my server with Google ConnectBot but not that way...

Here is my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
    android:minSdkVersion="19"
    android:targetSdkVersion="19" />

<application
    android:debuggable="true"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
      android:name="com.exemple.myapp.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    />
</manifest>

Thanks in advance for your help !

有帮助吗?

解决方案

If this.host is an Edit text then you have to call this.host.getText().toString() in jsch.getSession(). And the same for username and password, if they were Edit text objects, too.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top