2

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 !

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes it did works, I've done something stupide : host.tostring() and I forgot the getText(). All is okay now, thanks a lot !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.