使用Java通过腻子/跳跃服务器中的另一台服务器连接服务器

时间:2019-02-28 17:44:43

标签: java sftp putty scp winscp

使用Java代码登录腻子服务器后,我需要连接到另一台服务器,并且连接后需要从第二台服务器下载文件。有人有代码吗?

出现腻子服务器屏幕后,我输入用户名和密码,然后传递命令“ ssh服务器名”,然后我需要为出现的问题输入是。

完成上述操作后,我必须导航到其他文件夹并将文件下载到Server1。

我使用下面的代码连接到server1并已连接,之后我不确定要跳转到服务器2。

当我通过另一台服务器尝试远程服务器时,出现以下错误。我在下面输入的错误和代码

错误:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rich_media_container"
android:layout_width="match_parent"
android:layout_height="match_parent">

. . . . . . 

<LinearLayout
    android:id="@+id/cue_point_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingTop="16dp"
    android:paddingBottom="16dp"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/cue_points_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginTop="32dp"
            android:layout_marginEnd="8dp" />

    . . . . . . 

</LinearLayout>

我使用的代码:

Exception in thread "main" com.jcraft.jsch.JSchException: connection is closed by foreign host
        at com.jcraft.jsch.Session.connect(Session.java:236)
        at com.jcraft.jsch.Session.connect(Session.java:150)
        at putty.putty.main(putty.java:42)

我正在使用最新的jsch jar 0.1.55。有人可以调查一下,让我在这里丢失的内容吗。

2 个答案:

答案 0 :(得分:0)

尝试将 jsch 更新为0.1.55 https://mvnrepository.com/artifact/com.jcraft/jsch/0.1.55

您当前的版本0.1.42已有10年的历史了。它可能不会改变任何东西或可能会有所帮助。

答案 1 :(得分:0)

我能够使用plink命令通过Windows命令行实现我想要的